将参数传递给jquery ui对话框 [英] passing parameters to jquery ui dialog

查看:121
本文介绍了将参数传递给jquery ui对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 .data 这样传递调用对话框的文本框的id

  $(#<%= txtDirProprio.ClientID%>)。focus(function()
{
$(#<%= dialog.ClientID% >)。dialog(open).data(id,#<%= txtDirProprio.ClientID%>);
return false;
});

这里是对话框的代码

  $(#<%= dialog.ClientID%>)对话框({
autoOpen:false,
显示:blind,
hide:explode,
width:800,
height:200,
modal:true,
按钮:
{
Ajouter :function(){
$(this).dialog(close);
StringBuilderDir($(this).data(id));
},
Vider:function(){
$(this).dialog(close);
$($(this).data(id)).val()
$,
Cancelller:function(){
$(this).dialog(close);
}
},
open:function ()
{
var dir = $($(this).data(id)).val()。split( - );
if(dir [0]!=)
{
$(#<%= dd_dialog_directionvp.ClientID%>选项)每个(function(index)
{
if($(#<%= dd_dialog_directionvp.ClientID()%>选项)[index] .text == dir [0])
{
$ (#<%= dd_dialog_directionvp.ClientID()%>选项)[index] .selected = true;
}
})
}
}
});

所以 $(this).data(id)返回文本框的id。它工作正常,除了在开放功能。 id是未定义的



为什么它在按钮的功能中起作用,但不在打开的功能中。看起来不一样'这个'



谢谢

解决方案

pre $ {
$(#<%= dialog.ClientID%>)。data(id,#<%= txtDirProprio.ClientID%>)。dialog(open);
return false;
}) ;

在调用 .dialog('open')之前必须先设置数据;


I use .data like this to pass the id of the textbox that calls the dialog

$("#<%=txtDirProprio.ClientID%>").focus(function() 
{
         $("#<%=dialog.ClientID%>").dialog( "open" ).data("id","#<%=txtDirProprio.ClientID%>");
         return false;
});

here is the code for the dialog

 $("#<%=dialog.ClientID%>").dialog({
                autoOpen: false,
                show: "blind",
                hide: "explode",
                width: 800,
                height:200,
                modal: true,
                buttons: 
                {
                    "Ajouter": function() {
                        $( this ).dialog( "close" );
                        StringBuilderDir($( this ).data("id"));
                    },
                    "Vider": function() {
                        $( this ).dialog( "close" );
                        $( $( this ).data("id") ).val("")
                    },
                    "Canceler": function() {
                        $( this ).dialog( "close" );
                    }
                },
                open: function() 
                { 
                    var dir = $( $( this ).data("id") ).val().split("-");
                    if(dir[0] != "")
                    {
                        $("#<%=dd_dialog_directionvp.ClientID%> option").each(function(index) 
                        {
                            if ($("#<%=dd_dialog_directionvp.ClientID()%> option")[index].text == dir[0]) 
                            {
                                $("#<%=dd_dialog_directionvp.ClientID()%>  option")[index].selected = true;
                            }
                        })
                     }
                 }
                 });

So $ ( this ).data("id") returns the id of the textbox. It works fine except in the open function. The id is undefined

Why it works in the functions for the buttons but not in the open function. It looks like it's not the same 'this'

Thank you

解决方案

$("#<%=txtDirProprio.ClientID%>").focus(function() 
{
         $("#<%=dialog.ClientID%>").data("id","#<%=txtDirProprio.ClientID%>").dialog( "open" );
         return false;
});

Have to set the data first before calling .dialog('open');

这篇关于将参数传递给jquery ui对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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