Page 1 of 1

jquery event not firing

Posted: Fri Jan 20, 2012 11:59 am
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');
					});

Re: jquery event not firing

Posted: Fri Jan 20, 2012 2:31 pm
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.