Jquery.cascade plugin how to match text instead of value?

I am using the plugin from here . Thanks for this.

I use it for multiple dropdown menus. The thing is, I want it to filter the original list based on text, however the plugin only filters by value. Believe it is set on this line:

.filter(function() { return opt.match.call(this, opt.getParentValue(parent)); })

  • opt.match.call - Call matching method for dropdown menu
  • this is the list to filter
  • opt.getParentValue (parent) - returns the id of the selected value, this I want to change.

I just don't know how to change the plugin itself to provide the selectedItem or the text itself.

Any idea is appreciated. Thanks in advance. Cheers, H.

Edit:
I finally found a solution. I needed to change jquery.cascade.js like this:

getParentValue: function(parent) { return $(parent+" option:selected"); }

and then I can get the text value. :-) So my match criterion looks like this:

function matchStates(selectedItem) {
return this.When == selectedItem.val() && this.Where == selectedItem.text();
};


0


a source to share


1 answer


You want to define the function yourself and pass it in parameters when setting up the cascade.



    jQuery("#your_child").cascade("#parent_control", {
        getParentValue: function(parent) {
            // write code to return the text of
            // #parent_control instead of the value here
        }
    });

      

+1


a source







All Articles