What are event and UI parameters in Dialog

2020-08-21 03:23发布

问题:

What are event and UI parameters in jQuery Dialog? Can I get a mouse position using them?

$( ".selector" ).dialog({
   open: function(event, ui) { ... }
});

回答1:

The event parameter is the DOM Event object. The ui parameter is typically a hash; its properties depend on the event being raised.
For the dialog open event, both arguments appear to be null. For other events, such as dragStart, drag and dragStop, ui will contain the current position and offset:

$('.selector').dialog({
    drag: function(event, ui) {
        console.log("Current position: " + ui.position);
    }
});