views:

484

answers:

1

I am using plugin from here. Thanks for it.

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

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

  • opt.match.call - calls match method on dropdown
  • this - it is list to be filtered
  • opt.getParentValue(parent) - returns id of selected value, this I wanna change.

I just dont know how should I change the plugin itself to provide selectedItem or directly the text.

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

Edit:
Finaly I've found the solution. I needed to modified the jquery.cascade.js like this:

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

and then I could get to the text value. :-) So my match criterium looks like this:

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

+1  A: 

You want to define a function yourself and pass it in the options when you setup your cascade.

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