Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery how to keep settings after page reload using filtrify plugin?
    primarykey
    data
    text
    <p>First of all I would like to say that I have done my homework. I understand that javascript isn't supposed to keep it's settings after page reload.</p> <p>I also found 3 ways how this could be done:<br> 1. Cookies<br> 2. html local storage<br> 3. Ajax</p> <p>After trying to achieve this using html local storage, for several days, I've given up. I found this tutorial, which allows to cache whole html interface - <a href="http://24ways.org/2010/html5-local-storage/" rel="nofollow">see "Caching a whole interface"</a>. I made some progress using this method, but ultimately I failed. </p> <p>This is my <a href="http://luis-almeida.github.io/filtrify/" rel="nofollow">filtrify</a> code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { var container = $("#itemListLeading"), pagination = $("#pagination"); function setLazyLoad () { container.find("img").lazyload({ event : "turnPage", effect : "fadeIn" }); }; function setPagination () { pagination.jPages({ containerID : "itemListLeading", perPage : 9, direction : "auto", animation : "fadeInUp", previous : "a.jprev", next : "a.jnext", callback : function( pages, items ){ items.showing.find("img").trigger("turnPage"); items.oncoming.find("img").trigger("turnPage"); } }); }; function destroyPagination () { pagination.jPages("destroy"); }; setLazyLoad(); setPagination(); var ft = $.filtrify("itemListLeading", "placeHolder", { close: true, // Close windows after tag select block : "data-original", callback: function ( query, match, mismatch ) { if ( mismatch.length ) $("div#reset").show(); // Show Reset else $("div#reset").hide(); $('.ft-label').parent() // Hide unrelated tags .find('li[data-count=0]').hide().end() .find(':not(li[data-count=0])').show().end(); $(".ft-selected li").css("display","inline-block"); // small tag display fix destroyPagination(); setPagination(); } }); $("div#reset span").click(function() { // Make reset button clickable ft.reset(); }); }); &lt;/script&gt; </code></pre> <p>This was my shot at local storage implementation:</p> <pre><code> $(function() { var edit = document.getElementById('filter-menu'); $(edit).blur(function() { localStorage.setItem('todoData', this.innerHTML); }); // when the page loads if ( localStorage.getItem('todoData') ) { edit.innerHTML = localStorage.getItem('todoData'); } $("#reset span").click(function() { // Reset cache button localStorage.clear(); location.reload(); }); }); </code></pre> <p>Problems I experienced:<br> 1.Cache didn't always work (I got better result using .click function)<br><br> 2.When cache did work it cached state of filter settings(pressed butons), but all filter objects were displayed (instead of just those related to filter settings)<br><br> 3.I couldn't reset cache (reload worked) using reset button (last paragraph of code), although when I copied <code>localStorage.clear(); location.reload();</code> in firebug console cache got reset.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload