简体   繁体   English

jQuery UI对话框按钮

[英]jquery ui dialog button

With a jQuery UI dialog, I need to be able to set tooltips on buttons... I have the following code: 使用jQuery UI对话框,我需要能够在按钮上设置工具提示...我有以下代码:

buttons: {
 'My Button' : function(e) {
    $(e.target).mouseover(function() {
       alert('test'); 
    });
 }

This allows me to do something on "mouseover" but only once the button has been clicked. 这使我可以在“鼠标悬停”上执行某些操作,但仅在单击按钮后才可以。 What do I need to do in order to make this function before the button has been clicked? 在单击按钮之前,我需要做什么才能使该功能生效?

Thanks 谢谢

What you're going to want to do is have a handler for the "open" event on the dialog. 您要做的是在对话框上有一个处理“ open”事件的处理程序。 That handler will need to crawl up the DOM to the outer container <div> that the dialog code wraps your dialog content with. 该处理程序将需要将DOM爬到外部容器<div> ,该外部容器用对话框代码包装您的对话框内容。 From there, it needs to find the box where the buttons are, and then attach your handlers as appropriate. 从那里,它需要找到按钮所在的框,然后根据需要附加处理程序。

I can't remember exactly what the class names are (use Firebug) but the dialog code uses pretty obvious class tags to mark what the different containers are. 我不记得确切的类名是什么(使用Firebug),但是对话框代码使用了非常明显的类标记来标记不同的容器是什么。 There's an outer container, and then after your content box there's a <div> for the buttons. 有一个外部容器,然后在内容框后面有一个<div>按钮。 Again, bring up your dialog and use Firebug to see what the structure looks like. 同样,调出对话框并使用Firebug查看结构。

You can set up an "open" handler in your initialization options. 您可以在初始化选项中设置“打开”处理程序。

It may only fire events once it is clicked on because only that function is fired on click. 一旦单击它,它可能仅触发事件,因为单击时仅触发该功能。

Just select that button the normal way (eg $('#my-form button') ) and then do attach the mouseover event. 只需以常规方式选择该按钮即可(例如$('#my-form button') ),然后附加mouseover事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM