javascript - cancel postback in linkbutton when binding to jquery click event -
i have linkbutton binding click event using jquery, page still posts no matter try...
according this should able use event.preventdefault
however nothing seems work , posts back, but alert
here example
<asp:linkbutton runat="server" text="test" id="lnktest"></asp:linkbutton> <script> $(document).ready(function () { var lnk = $('#<%=this.lnktest.clientid %>'); lnk.unbind('click.test').bind('click.test', function (event) { alert("click"); event.preventdefault(); event.stoppropagation(); return false; }); }); </script>
update
okay after further investigation seems work expected when run in standalone page, using this script, , appears causing conflict..
that script moves href='javascript:... click handler, im guessing order handlers assigned may have it...
edit: i've tried reproducing without success. else in code differs this demo?
Comments
Post a Comment