0

Here is the essencial part of my custom code. I believe the onchange function is in confict with the function with the 3rd party plugin im using which also targets the same "option" tag.

    jQuery(document).ready(function(e) {
            var t = e("#filter-container");
            t.imagesLoaded(function() {
                t.isotope({
                    itemSelector: "figure",
                    filter: "*",
                    resizable: false,
                    animationEngine: "jquery"
                })
            });
$("select").on("change", function() {
    var select = $(this);
    var selectedOption = select.find("option:selected");
    var r = selectedOption.attr("data-filter");
    t.isotope({
      filter: r
    });
    return false
});
            e(window).resize(function() {
                var n = e(window).width();
                t.isotope("reLayout")
            }).trigger("resize")
        })

and here the probable culprit from the dropdown plugin im using. It is much longer than that but here the function that worries me which probably blocks my script:

    $("select").on("change", function() {
        var select = $(this);
        var selectedOption = select.find("option:selected");
        var n = select.parents(".filter-buttons");
        var r = selectedOption.attr("data-filter");
        t.isotope({
          filter: r
        });
        return false
    });

both function are part of seperate scripts so I cant join them together. Is there any way to make the second function not cancel the first one out?

http://jsfiddle.net/snz0gkkk/10/

Steve
  • 111
  • 8

1 Answers1

0

I tried to use your fiddle, but it didn't seem to work.

Try adding a unique namespace to your change event.

$("select").on("change.optionChange", function() {
    var select = $(this);
    var selectedOption = select.find("option:selected");
    var r = selectedOption.attr("data-filter");
    t.isotope({
      filter: r
    });
    return false
});
james emanon
  • 11,185
  • 11
  • 56
  • 97