I am trying to use jQuery.one on ajax loaded element. It is working if element is loaded already but not when element is being loaded using ajax.
Here is what I am trying to do.
$("#selector").one('mouseenter', selMouseEnter);
function selMouseEnter() {
Some code....
}
Thx in advance.
Shashi
EDIT:
$(".pitem").on('mouseenter', selMouseEnter);
$(".pitem").mouseleave(function(){
jQuery(this).find(".tooltip").remove();
$(".pitem").on('mouseenter', selMouseEnter);
});
function selMouseEnter () {
jQuery(this).find(".tooltip").remove();
var id = $(this).attr('id').replace('myprize', '');
var myObj = jQuery('#Py').data('myprize' + id);
if(myObj) {
Some code that is opening tooltip having buttons....
}
}
Now conflict is when I click on button in tooltip it is calling mouseenter event again and not the one specific to the button.
Note: #PY comes using ajax
Because it is dynamically loaded element you need to use .live() or .on() or livequery(). Refer links for more info – Use appropriate method depending upon your jquery version