I\'m using the jQuery one()
method on an event handler to fire once then de-register itself. Something like:
$(\".main\").one(\'mousedown\', \'.
just wrap that code in a function
function mainMouseDownOne() {
$(".main").one('mousedown', '.resizeBar', function (e) { /* my code */ });
}
$(document).ready(function(){
mainMouseDownOne();
.ajax({
...
success: function() {
...
mainMouseDownOne();
}
})
});
I would recommend wrapping the one() method bind inside a function call, then you can call the function (to bind the initial event handlers) on page load, and again on success of the Ajax call.
var bindEvents = function(){
$(".main").one('mousedown', '.resizeBar', function (e) { /* my code */ });
};
$(function(){ bindEvents(); }); // call the one() method on page load.
$.post(pageURL, function(data){
bindEvents(); // As an example, after some sort of Ajax or post-reset event.
});