Anu
Anu

Reputation: 67

On change select box option event is slow

Am having a drop-down with the class name user_status.

On the change event of this seletion, there is a dialog popup is coming. Here is the code.

$('.user_status').change(function(){
    $('#dialog-confirm').dialog({
        title     : 'Change Status',
        resizable : false,
        width     : 250,
        height    : 120,
        modal     : true,
        buttons   : {
            'Yes': function() {
                dialog_obj.dialog('close');
            },
            'No': function() {
                $(this).dialog('close');
            }
        }
    }); 
});

My problem is Its very slow(may take 3 or 4 seconds) to come this popup on the change event. How Can I fast this popup on change event?

Upvotes: 0

Views: 983

Answers (1)

silly
silly

Reputation: 7887

define your dialog before and just open the jquery dialog on event like this (untested code):

var jDialog =  $('#dialog-confirm').dialog({
        title     : 'Change Status',
        resizable : false,
        width     : 250,
        height    : 120,
        modal     : true,
        autoOpen  : false,
        buttons   : {
            'Yes': function() {
                dialog_obj.dialog('close');
            },
            'No': function() {
                $(this).dialog('close');
            }
        }
    }); 
$('.user_status').change(function(){
   jDialog.dialog('open');
});

Upvotes: 1

Related Questions