从javascript对象创建jquery对话框 [英] create jquery dialog from javascript object

查看:97
本文介绍了从javascript对象创建jquery对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个呈现html的javascript/jquery对象-一个具有表和编辑按钮的div,以及一个jquery弹出对话框.

I have an javascript / jquery object that renders html - a div with a table and an edit button, and a jquery popup dialog.

我一直在$(document).ready(function(){});

创建对象时是否可以创建对话框.

Is it possible to create the dialog when I create the object.

换句话说

object = new newTable('div_id');

对象中有

$(document).ready(function()
{
    $( "#" + this.popup_id ).dialog(
        {
            autoOpen: false,
            height: 600,
            width: 600,
            resizable: false,
            modal: true,
            buttons: 
            {
                "Next": function() 
                {
                    process_account_wizard('next');


                },
                "Skip": function() 
                {
                    process_account_wizard('skip');


                },
                Cancel: function() 
                {
                    $( this ).dialog( "close" );
                }
            },
            close: function() 
            {
            },

        });

});

因此,当文档准备就绪时,对象将设置对话框.

so when the document is ready the objects sets up the dialog.

另一个问题是,页面加载后是否可以自动为对象运行初始化代码?

An alternate question is can I automatically run initialization code for an object once the page is loaded?

我已经确认我可以首先创建对象,然后在文档准备功能中运行object.init(),对话框将正常工作.试图避免这种情况,使对象自动执行此操作.

I have confirmed I can first create the object then run object.init() in the document ready function and the dialog works correctly. Trying to avoid this an make the object do it automatically.

我可能不得不编辑几次该问题才能弄清楚如何提出该问题.谢谢您的帮助

I might have to edit this question a few times to figure out how to ask it. Thanks for your help

推荐答案

基本上,您想转换您的object变量(尽管我想想一个比对象"更合适的名称)并针对那个.

Basically you want to convert your object variable (though I'd want to think up a more appropriate name than "object") and initialise the dialog against that.

因此,在任何调用object = new newTable('div_id');的函数中,将您的对话框初始化粘贴到问题替换中-

So, within whatever function calls object = new newTable('div_id'); paste your dialog initialisation from your question replacing -

$( "#" + this.popup_id ).dialog(

使用

$(object).dialog(

这篇关于从javascript对象创建jquery对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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