Html Select List: why should you call twice?

I have a select list page (ASP.NET MVC page)

The selected list and onchange event are listed as follows:

<%=Html.DropDownList("CompanyID", Model.CompanySelectList, "(select company)", new { @class = "data-entry-field", @onchange = "companySelectListChanged()" })%>

Is companySelectListChanged function called twice?

I use excellent code in this question to get the caller.

both times the caller is an onchange event, however, if I look at the caller using:

arguments.callee.caller.caller

the first call returns some system code as the caller (I suppose), and the second call returns undefined.

I check that undefined only reacts once on onchange, but that doesn't seem ideal, can whcy be called twice?

UPDATE:

ok, !... :-), companySelectListChanged - .

onchange , . companySelectListChanged.

.. "data-entry-field", javascript , . , onchange , companySelectListChanged ?

:

$('. data-entry-field'). bind ('keypress changeup', function (e) {highLightSaveButtons();});

, 2 , , - ?

?

:

select , , 'change'. "change", , "onchange" .

jQuery, , , onchange jquery ? , , , IE jquery.

+5
2

. http://gutfullofbeer.net/onchange.html, jQuery DOM 0 (, "onchange" ). , jQuery , , jQuery IE.

iQuery 6593.

+3

IE8 , .

onchange jquery.change().

:

@Html.DropDownList("drpList", myList, new { @class = "myClass", id = "drpList" })

Script:

$(function () {
  $('#drpList').change(function () {
  .... your functionality
  });
});

.. .

+2

All Articles