开发者

problem with jQuery and MicrosoftAjax

<form action="#" id = "form1">    
     <input type="submit" value="submit" />
</form>
<input type="button" onclick="$('#form1').submit();" value="submit2" />
<script type="te开发者_运维百科xt/javascript">
    Sys.UI.DomEvent.addHandler(
        document.getElementById("form1"),
        'submit',
         function() { alert("abc"); return false; }
         );
</script>

When I click submit2, it doesn't alert, why?

And how can I fix this?


This does not trigger a submit of the form:

<input type="button" onclick="$('#form1').submit();" value="submit2" /> 

From the jQuery documentation: 'Note: This does not execute the submit method of the form element! If you need to submit the form via code, you have to use the DOM method, eg. $("form")[0].submit();'


$("form").bind("submit", function(e){
    var formContext = this[Sys.Mvc.FormContext._formValidationTag];
    if(formContext != null) formContext._form_OnSubmit(e);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜