guys!
I am really doing my best to solve the problem below, but after many hours I am not able to see the correct path to go! Let me explain:
Any ideas? Thank yo sooo much. G.
<script>
$(document).ready(function() {
$('#opener').click (function() {
$('#target').load ('http://my.url', function(){
$('#target').dialog({
title: 'My Title',
draggable: true,
dialogClass:'My Class',
modal: true,
hide: { effect: 'fade', speed: 'fast' },
show: { effect: 'fade', speed: 'fast' },
closeOnEscape: true,
closeText: 'Close',
beforeClose: function(event, ui) {
'window.location.reload(true)'
},
});//end dialog
});
$(this).addClass('.deactivated');
$(this).removeAttr('id');
});
});
Removing the ID from the element doesn't remove any handlers bound on that element (unless you had used "event delegation").
Either bind on the click event using .one
(instead of .on
or the obsolete .bind
) which then automatically unbinds the handler after it fires the first time:
$('#opener').one('click', ...)
Or disable the event within the click handler:
$('#opener').on('click', function() {
...
$(this).off('click').addClass('.deactivated');
});
NB: it's good practise to always use the newer .on
(or .one
) and .off
functions instead of .bind
, or .click
, etc. It makes event handling code more consistent and avoids confusion with how .click
can be used to both register an event handler or (without parameters) trigger the event handlers.
Description
.one(), Attach a handler to an event for the elements. The handler is executed at most once per element.
$('#opener').one('click',function(){
//your code
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With