javascript - jQuery - Bind Unbind click event depending of condition -


i need disable click event jquery mobile button depending if array empty or not. when location loads don't want user able click, once array has values, change that.

this have tried:

if (points.length != 0){ $('#addplaces').bind('click');} else{$('#addplaces').unbind('click');} 

i have tried same condition with:

$('#addplaces').on('click'); $('#addplaces').off('click'); 

what doing wrong? thanks!

why wanna that. return event when array empty , continue execution otherwise.

$('#addplaces').on('click', function() {      if (points.length === 0) {         return     } }); 

this way need not keep toggling event.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

json - ORA-06502: PL/SQL: numeric or value error: character string buffer too small - Convert Clob to varchar2 -

ios - Swift Array Resetting Itself -