Skip to main content

Dialog Click listener not triggering in IE8 or Firefox with jQuery



I have this click listener and for some reason it's not triggering in IE8 or Firefox:







console.log("listener attached");



jQuery(".ui-button-text").click(function() {



console.log("this should have triggered");



var ajaxUrl = '/ajax.php?popup=true';



var dataString = "param="+param+"&param2="+param2;



// contruct the ajax request

jQuery.ajax({

url: ajaxUrl,

dataType: 'json',

data: dataString,

beforeSend: function() {

jQuery(".ui-button-text").html("Saving...");

},

complete: function() {

jQuery(".ui-dialog-content").dialog("close");

},

success:function(response){



}

});



});







So I can see the "listener attached" in the console, but I don't see the click trigger, this works in chrome, what am I doing wrong here?





Thanks!





UPDATE: I have tried using live("click", function()... instead but it's not triggering





UPDATE: So another Update, I should mention that the content of this dialog is acquired through a separate page. It's loaded with AJAX, this dynamically loaded content contains this click listener.





UPDATE: Here is the code that loads the content, please be aware I didn't actually write this piece of code, so I don't fully understand why its done the way it's done here:







<!-- START OF NEW WINDOW POPUP -->

jQuery('.option_window').click(function(){

var url = jQuery(this).attr('href');

var title = jQuery(this).attr('title');

jQuery('<div />').dialog(

{

autoOpen: false,

width: 720,

title: "Manage Code",

modal: true,

buttons:{

"Save and Return":function() {

var self = this;



var popupForm = jQuery("form.submit_on_close");

//if( jQuery("form.submit_on_close").attr('action') != '#' || jQuery("form.submit_on_close").attr('action') != '') {

if(popupForm.attr('action') != '#' || popupForm.attr('action') != '') {

jQuery.ajax({

url: jQuery("form.submit_on_close").attr('action'),

dataType: 'json',

data: jQuery("form.submit_on_close").serialize(),

success: function(data) {

data = eval(data);

if(data.resp == "success") {

var obj = jQuery('#repl_activation_row');

obj.unbind('mouseover');

if( data.property_code > 0) {

if( obj.hasClass('codeoff') ) {

obj.removeClass('codeoff').addClass('codeon');

}

} else {



if( obj.hasClass('codeon') ) {

obj.removeClass('codeon').addClass('codeoff');

}



}

}

jQuery(self).dialog('close');

}

});

}

else

jQuery(self).dialog('close');

}

},

//title:title,

open: function(event, ui){



jQuery(".ui-dialog").delay(600).queue(function(n) {

var topPos = jQuery(".ui-dialog").offset().top;

var finalPos = topPos - (jQuery(".ui-dialog").height() / 3);

jQuery(".ui-dialog").css("top", finalPos);

n();

});







var self = this;

jQuery.getJSON(url, {}, function(data){

jQuery(self).html(data);

});

},

close: function(event, ui){ jQuery(this).dialog( "destroy" ); jQuery(this).remove(); }

}).dialog('open');

return false;

})

<!-- END OF NEW WINDOW POPUP -->







And here is the link:







<a href="/popupmanager.php?code=3212&client=4432" class="actions option_window menulink">Manage</a>





Source: Tips4all

Comments

  1. I figured it out, I needed to attach the listener to ui-button:

    jQuery(".ui-button").live("click", function() {


    Not

    jQuery(".ui-button-text")


    I don't know why this is the case, I can't believe it took me this long to figure out, sorry guys, wish I could have given the points to one of you..

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.