开发者

maintain current page when updating top level parameter in MVC

开发者 https://www.devze.com 2023-01-26 07:20 出处:网络
After working on a page for quite some time, the customer now decided that they wan\'t to be able to change a top level setting but still maintain the current page they\'re in.

After working on a page for quite some time, the customer now decided that they wan't to be able to change a top level setting but still maintain the current page they're in.

Say for example:

User goes to default page, clicks on the UserSettings which is loading a partial view. In that partial there is multiple links like Address, Password, Other. Click Address (any of these) and it will load a partial within the partial. This will of course maintain the link "MyProject/User/1" in the URL bar.

When the User now change in the drop down in the top level, from User 1 to User 2 this will update the URL to be "MyProject/User/2" and will load the matching action with that. However, I wan't to be able maintain the user selection from before (MyProject/User/2, click UserSettings, click Address).

If I knew this from the 开发者_如何学JAVAbeginning I would have done it completely different, but this now a request from the customer after the project is done so I'm look into if there is any "easy" way to solve this or not.

<select id="drpUser" >
   <option id="1" </option>
   <option id="2" </option>
   <option id="3" </option>
</select>


$("#drpUser").change(function(event){       
    window.location = '/User/Index/' + $("#drpUser :selected").attr('id');
});

I can also add that I've tried to do something like this to figure out what exact page I'm on:

var foo = window.location.pathname;

but that only gives me what ever I already have in the URL bar, and not any information about what partial that potentially would be loaded. Is there any way to see what partials is dynamically loaded at the moment?

Basically loading View -> Partial View -> Partial View. Changing the setting for the View but still want to maintain View -> Partial View -> Partial View, but now for the new User


One option would be to load the UserSettings in a dialog window using a tab for different section (Address, Password, Other). And then update the main page accordingly.

If this is a good option for you, please better explain what is "the dropdown in the top level" and add some of your code to let people better understand the question


I'm afraid there isn't any way to do this at the moment, and that's the answer for now.

0

精彩评论

暂无评论...
验证码 换一张
取 消