开发者

How to pass variable to dialog in jQuery

开发者 https://www.devze.com 2023-03-22 21:15 出处:网络
When clicking this: $(\'.hor_edit\').live(\'click\', function(e) { e.preventDefault(); var name = $(this).attr(\'name\');

When clicking this:

$('.hor_edit').live('click', function(e) {
                    e.preventDefault();
                    var name = $(this).attr('name');
                    $('#dialog-for开发者_JS百科m-horario').dialog('open');
                });

I want to check the variable when clicking another button inside the dialog:

$('#dialog-form-horario').dialog({
            resizable: false,
            autoOpen: false,
            modal: true,
            buttons: {

                'Agregar': function() {
                                    alert(name);
                }
            },

            close: function() {
            }
        });

I've read the documentation but seems not clear to me.


Try

var name = $(this).attr('name');
$('#dialog-form-horario').data('name', name);
$('#dialog-form-horario').dialog('open');

and

'Agregar': function() {
    alert($(this).data('name'));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消