lundi 20 juin 2016

My Script load too late

I try to use a script for prefilter ISOTOPE from an other page, but my Isotope script doesn't load my value with the filter value. You can test by yourself here : http://aprime-industries.com/

Just click on "Nos Références" and click on ENTI for exemple.

enter image description here

You will see my dropdown list is "ENTI" selected but the filter is not active, I need to click on "Indifférent" and click again on ENTI for activate the filter and the data-filter-value.

<option value="ENTI" data-filter-value=".ENTI">ENTI</option>

enter image description here

I will give you my script for link the value from the dropdown list :

function getParameterByName(name) {
    name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");
    var regex = new RegExp("[\?&]" + name + "=([^&#]*)"),
    results = regex.exec(location.search);
    return results == null ? "" :  decodeURIComponent(results[1].replace(/+/g, " "));
}

And

$(document).ready(function(){
    var preSelected = getParameterByName("filter");

    if(preSelected == "ENTI") {
        $('select[name="societe"]').val("ENTI");
    }
    else if(preSelected == "S2MI") {
        $('select[name="societe"]').val("S2MI");
    } 
    else if(preSelected == "JBM41") {
        $('select[name="societe"]').val("JBM41");
    }
});

And my href link :

<a href="plaquettes?pre=ENTI" class="hvr-bounce-out"><img src="img/entilogo.png" class="" alt="icone ENTI"></a>
<a href="plaquettes?pre=S2MI" class="hvr-bounce-out"><img src="img/s2milogo.png" class="" alt="icone S2MI"></a>
<a href="plaquettes?pre=JBM41" class="hvr-bounce-out"><img src="img/jbm41logo.png" class="" alt="icone JBM41"></a>

I make a jsfiddle for my isotope script JSFIDDLE

Aucun commentaire:

Enregistrer un commentaire