I am trying to pass not only the dropdownlist ID using this, but I'm also trying to pass the row.
<asp:DropDownList ID="dropdownPhase" _clientId="comboboxPhase" runat="server" Font-Size="xx-small" onchange="SummaryHelper.onPhaseChange(this,this.tr);" />
Here is the Javascript from my JS File
onPhaseChange: function(dropdown, row) {
var combobox = $(dropdown);
var table = combobox.parents("table").eq(0);
comboboxWorkUnit = row.find("select.workUnit");
if (combobox.data('oldValue') || !combobox.find("option[value='']").length) {
comboboxWorkUnit.hide();
}
},
When I run it the way it is I get this error:
Microsoft JScript runtime error: 'undefined' is null or not an object
Well this.tr
is nothing. I'd be curious to know where you got that.
If you want to pass the row, you'll need to get the row just like you are in the function.
onchange="SummaryHelper.onPhaseChange(this,$(this).closest('tr'));"
This passes a jQuery object with the row since you're using it like a jQuery object in the function.
But then you could just do it in the function too.
onPhaseChange: function(dropdown) {
var combobox = $(dropdown);
var row = combobox.closest('tr');
var table = combobox.parents("table").eq(0);
comboboxWorkUnit = row.find("select.workUnit");
if (combobox.data('oldValue') || !combobox.find("option[value='']").length) {
comboboxWorkUnit.hide();
}
},