Showing posts with label click. Show all posts
Showing posts with label click. Show all posts

Friday, May 18, 2012

jQuery click off element event


I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() funtion callback when hovering off an element. Only I want to do this for click.

Sunday, April 22, 2012

Android - play sound on button click - Null pointer exception


I am trying to play a sound file on the click of a button. The sound is just 1 sec long. It plays well the first few times I click the button, but after a while it gives a NullPointerException. Here's the code:

Sunday, April 8, 2012

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

Monday, February 27, 2012

Eclipse: Android Soundboard buttons are "overclickable&rdquo;


In my android soundboard, all of the buttons work perfectly and the sounds play normally, but there is a problem. The problem is that when you press a button in the app, you can press other buttons. For instance, if the button I press plays a siren like noise, I can press another button and both sounds will play at the same time. This is not what I want. Is there any code I can add to make it so that I can click only one button at a time, or some code that makes the previous sound stop and it will play the newly selected sound?

Monday, February 13, 2012

Running JQuery or Javascript on Facebook


I am trying to execute a simple bit of jQuery or JavaScript once logged in to my Facebook account. The end goal at this moment is to click on my custom feed once the element is visible, rather than having it default to the entire Facebook friend feed.

Sunday, February 12, 2012

Monday, January 30, 2012

Wednesday, January 18, 2012

Multiple object selection with jQuery




I have a pretty basic jQuery question and forgive me if it has already been answered. Basically I attempt to have a link slide down a div. This is fairly simple however I require multiple links sliding down their respective divs. I understand I can just name the links and divs unique classes and solve the problem that way, however this naturally also requires a duplication of the jQuery code for each link-div and i have a lot. I therefore need a general script. A simplified version of my situation is as follows: