更新 MVC 中的顶级参数时保持当前页面
在页面上工作相当长一段时间后,客户现在决定他们不希望能够更改顶级设置,但仍保留他们所在的当前页面。
例如:
用户转到默认页面,单击在正在加载部分视图的 UserSettings 上。在该部分中有多个链接,例如地址、密码、其他。单击地址(其中任何一个),它将在部分中加载部分。这当然会在 URL 栏中保留链接“MyProject/User/1”。
当用户现在在顶层下拉列表中更改时,从用户 1 更改为用户 2,这会将 URL 更新为“MyProject/User/2”,并加载与之匹配的操作。但是,我不希望能够保留之前的用户选择(MyProject/User/2,单击 UserSettings,单击 Address)。
如果我从一开始就知道这一点,我会做完全不同的事情,但现在这是项目完成后客户的请求,所以我正在研究是否有任何“简单”的方法 解决这个问题还是不解决这个问题。
<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');
});
我还可以补充一点,我尝试做这样的事情来弄清楚我所在的确切页面:
var foo = window.location.pathname;
但这只提供了我在 URL 栏中已有的内容,而不提供任何有关可能会出现的部分的信息被加载。有什么方法可以查看目前动态加载的部分内容吗?
基本上加载视图 ->部分视图 ->部分视图。更改 View 的设置但仍想保留 View ->部分视图 ->部分视图,但现在针对新用户
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 beginning 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种选择是使用不同部分(地址、密码、其他)的选项卡在对话框窗口中加载用户设置。然后相应地更新主页。
如果这对您来说是一个不错的选择,请更好地解释什么是“顶层下拉菜单”并添加一些代码,以便人们更好地理解问题
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.