Guys I have 2 questions which is i think related in some ways I guess. First:
- What is the difference between these two: - $(document).on('click','#someselector', function() { //do something });
vs this
$('#selector')on('click', function(){
  /do something
});
Sometimes both works, sometimes it doesn't.
Number 2 question:
I created a jQuery UI dialog like this:
function this_dialog(id) {
    $("#div-id-for-the-dialog").dialog({
        autoOpen            : false,
        modal               : true,
        draggable           : false,
        width               : 400, 
        buttons         : [{ 
            id      : id,
            text    : 'Ok' 
        },{  
            text    : 'Cancel',
            click   : function () { 
                $("#div-id-for-the-dialog").dialog('close');
            }
        }]   
    });  
}
So as you can see, the id is passed to the function, many will call this dialog and pass a unique id to it. The id will then be assigned only to the Ok button.
So when i call this function to load a unique dialog:
add_section_complete_reopen_dialog('my-unique-dialog-id'); //passing the id
$('#div-id-for-the-dialog').html("I have a unique dialog now? ok?");
When i press ok with this code:
$(document).on('click','#my-unique-dialog-id', function () {
  //Do some ajax call here
});
I get this JS error: TypeError: s is undefined 
But the ajax is successful. I just want to know what that error is.
So when I say it is related to the first question is because when i replace the click code with this:
$('#my-unique-dialog-id').on('click', function () {
  //Do some ajax call here
});
It doesn't work anymore.
Thanks
 
     
    