Html Select List: Why Would Onchange Be Called Twice?
I have a page with a select list (ASP.NET MVC Page) The select list and onchange event specified like this: <%=Html.DropDownList('CompanyID', Model.CompanySelectList, '(select c
Solution 1:
I agree with your assessment. I've updated my small example at http://gutfullofbeer.net/onchange.html to include a jQuery handler in addition to the DOM 0 handler (the one set with the "onchange" attribute). It appears to be a jQuery bug, or at least a failure of jQuery to deal with the IE weirdness.
I logged jQuery ticket 6593.
Solution 2:
I also encountered this issue when using IE8 and made some changes to fix this.
Instead of specifying the onchange event on the dropdownlist, I used the jquery.change() event.
Markup:
@Html.DropDownList("drpList", myList, new { @class = "myClass", id = "drpList" })
Script:
$(function () {
$('#drpList').change(function () {
.... your functionality
});
});
This works for me.. Hopes this help.
Post a Comment for "Html Select List: Why Would Onchange Be Called Twice?"