Jquery live() click is making multiple instances of uploadify, how can I stop it from doing it -


uploadify live click , toggle creating multiple instances of upload button how can stop doing that.

my code:

// display sub comments form             $(document).find("div[id^='subreply-']").live('click', function(){                     var num = this.id.split('-')[1];                     $('#subboxes-' + num).toggle();                       $('#file_upload1-' + num).uploadify({                         'uploader'  : 'js/uploadify.swf',                         'script'    : 'js/uploadify.php',                         'cancelimg' : 'js/cancel.png',                         'folder'    : 'upload',                         'auto'      : true,                         'multi'     : false,                         'oncomplete' : function(event, queueid, fileobj, response, data) {                                              $("#commentfile-" + num).val(fileobj.name);                                        }                       });                  }); 

what doing wrong?

thanks

how quick fix?

var uploadify_instances = {};  $(document).find("div[id^='subreply-']").live('click', function(){             var num = this.id.split('-')[1];              if(!uploadify_instances['#file_upload1-' + num]) {               uploadify_instances['#file_upload1-' + num] = true;               $('#subboxes-' + num).toggle();                $('#file_upload1-' + num).uploadify({                 'uploader'  : 'js/uploadify.swf',                 'script'    : 'js/uploadify.php',                 'cancelimg' : 'js/cancel.png',                 'folder'    : 'upload',                 'auto'      : true,                 'multi'     : false,                 'oncomplete' : function(event, queueid, fileobj, response, data) {                                      $("#commentfile-" + num).val(fileobj.name);                                }                 });              }     }); 

edit: yup, i've made unnecessary complicated @ first.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -