button event is not working in fire fox os

后端 未结 2 1030
别跟我提以往
别跟我提以往 2021-01-23 11:45
function listContents(storagename) {

    alert(\"inside function\");
    //Clear up the list first
    $(\'#results\').html(\"\");
    var files = navigator.getDeviceSt         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-23 12:06

    Your problem:

    You are creating an element upload on onsuccess function call. This call can be made after some time-async and your binding onclick is made on spot, when your #upload button may not be yet added to DOM. That is why you need to attach click event to an alement that is already present in DOM, like results:

    That is why you need to get existing element (results) and bind: in any #upload will be attached to this one, give him this onclick event.

    $('#results').on('click', '#upload', function () {
        // Handler here
    });
    

    I hope I had explained your problem.

    UPDATE: You could move your click binding under line:

    console.log('button uploded!' + r);
    

    This way your click event will be added only when your upload button is attached.

提交回复
热议问题