Guilherme Longo
Guilherme Longo

Reputation: 2308

2 approachs for creating a jquery dialog.

I have 2 different approaches to create a dialog with Jquery

This one don´t work:

 var options = "{width: 1024, height: 600, modal: true, buttons: { Cancelar: function () { $(this).dialog('close'); } }, draggable: false, resizeble: false}";

$('#UserSettings').dialog(options);

and this one works fine:

$('#UserSettings').dialog({ width: 1024, height: 600, modal: true, buttons: { Cancelar: function () { $(this).dialog('close'); } }, draggable: false, resizeble: false });

Can´t figure out why.

Upvotes: 1

Views: 56

Answers (1)

Selvakumar Arumugam
Selvakumar Arumugam

Reputation: 79850

Remove the quotes for the options in the first one. The argument to the dialog is an object and not string.

var options = {  
        width: 1024, 
        height: 600, 
        modal: true, 
        buttons: { 
           Cancelar: function () { 
              $(this).dialog('close'); 
           } 
        },
        draggable: false, 
        resizeble: false
 };

Upvotes: 5

Related Questions