Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
铁路及;Javascript-如何将某些内容标记为已查看或已读取?_Javascript_Jquery_Ruby On Rails - Fatal编程技术网

铁路及;Javascript-如何将某些内容标记为已查看或已读取?

铁路及;Javascript-如何将某些内容标记为已查看或已读取?,javascript,jquery,ruby-on-rails,Javascript,Jquery,Ruby On Rails,如何在用户单击某行时将某个内容标记为已查看。 下面是我试图解释的一个例子:尝试单击一行并返回。您将看到该行标有复选标记。所以你知道你已经看到了 如何创建类似的内容?您希望保存一个AJAX历史状态。在这里可以找到两个惊人的Rails和Javascript教程: 第一个链接将引用第二个链接 来自Ryan Bate的网站| /*application.js*/ if(history&&history.pushState){ $(函数(){ $(#products th a,#products.pa

如何在用户单击某行时将某个内容标记为已查看。 下面是我试图解释的一个例子:尝试单击一行并返回。您将看到该行标有复选标记。所以你知道你已经看到了


如何创建类似的内容?

您希望保存一个AJAX历史状态。在这里可以找到两个惊人的Rails和Javascript教程:

  • 第一个链接将引用第二个链接

    来自Ryan Bate的网站|

    /*application.js*/
    if(history&&history.pushState){
    $(函数(){
    $(#products th a,#products.pagination a”).live(“单击”,函数(e){
    $.getScript(this.href);
    history.pushState(null,document.title,this.href);
    e、 预防默认值();
    });
    $(“#产品搜索输入”).keyup(函数(){
    $.get($(“#产品搜索”).attr(“操作”),$(“#产品搜索”).serialize(),null,“脚本”);
    history.replaceState(null,document.title,$(“产品搜索”).attr(“操作”)+?“+$(“产品搜索”).serialize());
    });
    $(window.bind(“popstate”,function()){
    $.getScript(location.href);
    });
    });
    }
    /*products/index.js.erb*/
    $(“#产品”).html(“”);
    document.title=“”;
    
    我们不会为您提供“详细示例”,但我们会为您提供一般性指导,您可以提出具体问题。一般性指导可以:)。
    /* application.js */
    if (history && history.pushState) {
      $(function() {
        $("#products th a, #products .pagination a").live("click", function(e) {
          $.getScript(this.href);
          history.pushState(null, document.title, this.href);
          e.preventDefault();
        });
        $("#products_search input").keyup(function() {
          $.get($("#products_search").attr("action"), $("#products_search").serialize(), null, "script");
          history.replaceState(null, document.title, $("#products_search").attr("action") + "?" + $("#products_search").serialize());
        });
        $(window).bind("popstate", function() {
          $.getScript(location.href);
        });
      });
    }
    
    /* products/index.js.erb */
    $("#products").html("<%= escape_javascript(render("products")) %>");
    document.title = "<%= escape_javascript("#{params[:search].to_s.titleize} Products by #{(params[:sort] || 'name').titleize} - Page #{params[:page] || 1}") %>";