将jQuery UI Button添加到从Ajax加载的UI Dialog [英] Add jQuery UI Button to UI Dialog loaded from Ajax

查看:93
本文介绍了将jQuery UI Button添加到从Ajax加载的UI Dialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在打开和关闭使用ajax动态创建的对话框。我希望能够让对话框中出现的按钮使用jQuery UI按钮。我可以通过调用$(button)。button()来做到这一点,但这会影响每个按钮元素。如何才能仅影响此对话框中显示的按钮?

I'm opening and closing dialogs that are dynamically created using ajax. I'd like to be able to have the buttons that appear on the dialogs use the jQuery UI button. I can do this by calling $("button").button(), but that affects every button element. How can I be specific to only affect the buttons that appear on this dialog?

var $dialog = $('<div>').load('/Dialog').dialog({
    autoOpen: false,
    title: 'Dialog',
    height: 250,
    width: 750,
    resizable: false,
    modal: true,
    show: "fadeIn",
    hide: "fadeOut"
});
$('#btnOpenDialog').click(function () {
    $dialog.dialog('open');
    return false;
});


推荐答案

我将使用jAndy的建议并使用对话框纽扣。我试图在我通过ajax加载的HTML页面中使用已有的按钮。对话框按钮执行我需要它们做的事情并且看起来更干净。

I'll use jAndy's suggestion and just use the Dialog buttons. I was attempting to use already existing buttons in a HTML page I was loading through ajax. The dialog buttons do what I need them to do and look cleaner.

这篇关于将jQuery UI Button添加到从Ajax加载的UI Dialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆