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 :

  1. http://railscasts.com/episodes/246-ajax-history-state

  2. http://railscasts.com/episodes/175-ajax-history-and-bookmarks

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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -