jquery - Rails & Javascript - How to mark something as viewed or read? -
how mark viewed when user clicks on row. here example trying explain: http://www.dba.dk/dyr/hunde-og-tilbehoer/racehunde/race-labrador/ try click on row , go back. see row marked check sign. know have seen it.
how create it?
you're looking save ajax history state. 2 amazing rails , javascript tutorials can found here :
the first link reference second.
from ryan bate's website | railscasts.com
/* 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 #{(params[:sort] || 'name').titleize} - page #{params[:page] || 1}") %>";
Comments
Post a Comment