jquery event not firing

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

jquery event not firing

Post by danwguy »

Not quite sure why this doesn't work, I have tried all variations of event delegations... .delegate() .mousedown() .delegate() .bind() and .live(). The only one that works is live(), but since it's part of a context menu that will be added to the page many times and on many different elements, the live event is not an option. Any help would be greatly appreciated, I can't seem to see why this isn't firing off.

Code: Select all

$("#" + old_n).on('mousedown', function(evt) {
							console.log(old_n);
						if($(el).data('clickphase')) return true;
						$("#" + $.contextmenu).remove();
						$(el).data('served', true);
						if(typeof array_of_a[a_index][1] == 'function') {
							array_of_a[a_index][1](evt, el);
						}	
						//console.log(array_of_a[a_index]);			
						//array_of_a[a_index][1](evt, el);
						$(el).removeData('served');
					});
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: jquery event not firing

Post by tr0gd0rr »

Can you confirm that `$("#" + old_n)` selects the element you want? If so, try wrapping the body of your function in a try-catch block. If `el` is undefined, for example, an error will be thrown but jQuery will suppress the error.
Post Reply