- Details
- Written by: Stanko Milosev
- Category: jQuery
- Hits: 4033
So, I had a problem where ajax call was started, but user changed the page, and after ajax call was finished some js script will be executed and inf bubble will be shown to the user, in a place where it shouldn't be.
To check if page has changed you can use hash of a page:
$(window).hashchange(function () { self.xhr.abort(); console.log("abort"); });
Test self.xhr.abort() is actually aborting ajax call...
- Details
- Written by: Stanko Milosev
- Category: jQuery
- Hits: 3990
As much as I understood, razor's
@Html.CheckBox("myInputName", false)
Will create HTML like:
<input id="myInputName" name="myInputName" type="checkbox" value="true" checked="checked"> <input name="myInputName" type="hidden" value="false" checked="checked">
If you want with jQuery to select just input which is not hidden, use following code:
$('input[name=myInputName]:not([type=hidden])'
- Details
- Written by: Stanko Milosev
- Category: jQuery
- Hits: 3740
If you have form post method, like:
<form name="myForm" action="/myController/DoSomething?someId=myId" method="post">
and you want myId to change to something else, then you can use this code:
var myPom = $("form[name=myForm]").attr('action'); myPom = myPom.replace("myId", "123"); $("form[name=myForm]").get(0).setAttribute('action', myPom);