简体   繁体   English

如何让我的页面记住用户的最后操作?

[英]How do I get my page to remember user's last action?

We have a search form which allows users to search for items on the page. 我们有一个搜索表单,允许用户搜索页面上的项目。

There is also another form with checkboxes that allows users to refine their searches with the hope of reducing the number of search results. 还有另一种带有复选框的表格,允许用户优化搜索,以减少搜索结果的数量。

For instance, if I enter McCland on the search box and 13 results marching McCland are returned, I can click on Advanced search and a bunch of checkboxes are rendered. 例如,如果我在搜索框上输入McCland并返回了进行Mcland的13个结果,则可以单击Advanced search然后显示一堆复选框。

I can then check "Street" , "Road" , "LandMarks" , etc. I can then click search on McCland again. 然后,我可以检查"Street""Road""LandMarks"等。然后,我可以再次单击“搜索”。

This time, only addresses with Street or Road or LandMarks will be displayed if available. 这次,仅显示带有街道或道路或地标的地址(如果有)。

This works great. 这很好。

Then there is a Remember This Action icon. 然后有一个“ Remember This Action图标。

My biggest challenge so far is to allow users to click on this Remember This Action icon and save their current results. 到目前为止,我最大的挑战是允许用户单击“ Remember This Action图标并保存其当前结果。

This way, next time they visit the page, the results they searched for previously are presented to them unless they choose to search with another option. 这样,除非他们选择使用其他选项进行搜索,否则下次他们访问该页面时,会将以前搜索的结果显示给他们。

If they click on this Remember This Action icon, they will be prompted with a message explaining that they are about to save their current Results. 如果他们单击此“ Remember This Action图标,将提示他们一条消息,提示他们将要保存其当前结果。

They can click Yes to save or Cancel to not save. 他们可以单击“是”保存或单击“取消”不保存。

I suspect this will be done with cookies(jquery or Javascriot) but I am not sure how to do this. 我怀疑这将通过cookie(jquery或Javascriot)完成,但是我不确定如何做到这一点。

Any assistance is greatly appreciated. 非常感谢您的协助。

If you're looking for a jQuery solution you could use the JQuery Cookie Plugin: https://github.com/carhartl/jquery-cookie 如果您正在寻找jQuery解决方案,则可以使用JQuery Cookie插件: https : //github.com/carhartl/jquery-cookie

You're code might look something like this: 您的代码可能看起来像这样:

//Set the action
$.cookie('last_action', 'the_action');

//Get the action
var last_action = $.cookie('last_action');
if (typeof last_action != 'undefined') {
    // show last action
} else {
   //show default
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我试图让用户的浏览器“记住”他们上次访问页面时打开了可折叠菜单的哪个部分,然后重新打开它 - I'm trying to get the user's browser to “remember” which portion of a collapisble menu was open when they last visited a page and then reopen it 如何获取客户端用户的最后一条消息? - How do I Get the Client User's Last Message? 如何让 Javascript 记住在我的 function 中重置但最初在我的 function 之外定义的变量? - How do I get Javascript to remember a variable that is reset in my function, yet initially defined outside of my function? 如何让我的 for 循环在 NetSuite 的用户事件脚本中包含最后一行? - How do I get my for loop to include the last line in a user event script in NetSuite? 如何使用本地存储让我的文本输入字段记住以前输入的数据? - How do I get my text input field to remember previously entered data by using local storage? 如何在我的 web 页面的页脚中添加上次修改的内容? - How do I add last modified in the footer of my web page? 如何获取用户输入的访问权限并在我的后端服务器上计算某些内容? - How do I get the access of user's input and calculate something on my back-end server? 如何从API请求中获取JSON到我的页面的javascript中? - How do I get the JSON from an API request into my page's javascript? 如何判断我的页面是否设置为用户的主页? - How can I tell if my page is set as the user's homepage? 语言切换器 - 如何记住用户的选择? - Language switcher - How to remember user's choice?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM