打开jQueryUI对话框后如何执行函数? [英] How to execute function after opening a jQueryUI Dialog?
问题描述
在我的网页上,我有一些链接,如:
< div id =toolbarButtons>
< a href =realites / addLinkid =liens =lientitle =Insérerun lienclass =toolbarButton>< span>< img src =pub / struct / picto / icon_toolbar-link.gifalt =Liens/> Lien< / span>< / a>
< a href =realites / addImage =imagetitle =Insérerune imageid =imgclass =toolbarButton>< span>< img src =pub / struct / picto / icon_toolbar-img.gifalt =Liens/> (多个)图像和LT; /跨度>< / A>
< / div>
< div id =dialogbox>< / div>
首先我通过调用来初始化我的对话框:
$ b $对话框({
bgiframe:true,
autoOpen:false,
$,$,en,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
width:500,
modal:true
});
}
然后我将点击事件的对话框附加到
$('。toolbarButton')。click(function(e){
e.preventDefault();
actu.dialogManager ($(this));
});
dialogManager:function(elem){
elem.blur();
var title = elem.attr('title');
var href = elem.attr('href');
var rel = elem.attr('rel');
$('#dialogbox')。对话框('选项','标题',标题);
如果(rel =='lien')
{
$('#dialogbox')对话框('option','buttons',{
'添加':function(){
// TODO
},
'取消':function(){
$('#linkText')。val('');
$('#linkUrl')。val('');
$(this).dialog('close');
}
});
$('#dialogbox')。load(href).dialog('open');
}
}
如你所见,内容的对话框用ajax获取。该对话框包含一些输入。
我有一个最后一个函数,它应该编辑输入的内容,但我不知道如何和在哪里调用它。在对话框打开后需要调用才能有效。我该怎么做?
在
$ $ $ $ $ $ $ $ $ $ ( '#dialogbox')负载(HREF).dialog( '开放')。
由于异步加载(在对话框完全加载之前调用)不起作用。 p>
感谢您的帮助。
您可以在对话框中执行某些操作打开。
initDialog:function(){
$('#dialogbox')。 $ b bgiframe:true,
autoOpen:false,
open:function(){
//在加载
}上执行某些操作,
width:500,
modal:true
});
}
On my web page i have some links like :
<div id="toolbarButtons">
<a href="actualites/addLink" id="liens" rel="lien" title="Insérer un lien" class="toolbarButton"><span><img src="pub/struct/picto/icon_toolbar-link.gif" alt="Liens" />Lien</span></a>
<a href="actualites/addImage" rel="image" title="Insérer une image" id="img" class="toolbarButton"><span><img src="pub/struct/picto/icon_toolbar-img.gif" alt="Liens" /> Image(s)</span></a>
</div>
<div id="dialogbox"></div>
First of all i init my dialogbox by calling :
initDialog : function() {
$('#dialogbox').dialog({
bgiframe:true,
autoOpen:false,
width:500,
modal:true
});
}
then i attach the the dialog on click event :
$('.toolbarButton').click(function(e){
e.preventDefault();
actu.dialogManager($(this));
});
dialogManager : function(elem) {
elem.blur();
var title = elem.attr('title');
var href = elem.attr('href');
var rel = elem.attr('rel');
$('#dialogbox').dialog('option','title',title);
if(rel == 'lien')
{
$('#dialogbox').dialog('option','buttons',{
'Add' : function(){
//TODO
},
'Cancel' : function(){
$('#linkText').val('');
$('#linkUrl').val('');
$(this).dialog('close');
}
});
$('#dialogbox').load(href).dialog('open');
}
}
As you can see , the content of the dialog box is fetched with ajax. The dialog contain some input. I have a last function which is supposed to edit the content of the input but i don't know how and where to call it. It need to be called after the opening of the dialog to be efficient. How can i do that ?
doing it juste after
$('#dialogbox').load(href).dialog('open');
won't work because of the asynchronous loading (called before the dialog is fully loaded).
Thanks for your help.
You could do something when the dialog is opened.
initDialog : function() {
$('#dialogbox').dialog({
bgiframe:true,
autoOpen:false,
open: function() {
// do something on load
},
width:500,
modal:true
});
}
这篇关于打开jQueryUI对话框后如何执行函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!