开发者

How to pass variable to dialog in jQuery

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜