3

我是这方面的新手,我正在尝试将抖动效果应用于具有嵌入式表单但没有成功的对话框。

当我尝试触发效果时

$("#restore_password").effect("shake", {times: 3}, 80);

只有表单标签内的字段生效,但对话框本身没有。

我的 div

<html>
    <body>
        <div id="restore_password" title="Confirmation code" class="ui-widget-content ui-corner-all" >
           <form> <fieldset> <label for="code">Code</label> <input type="text" name="codecon" id="codecon" class="text ui-widget-content ui-corner-all" /> </fieldset> 
           </form> 
        </div>
    </body>
</html>

我的对话

$("#restore_password").dialog({
                height: 220,
                width: 310,
                autoOpen: false,
                modal: true,
                draggable: false,
                resizable: false,
                show: 'puff',
                hiden: 'puff',

                buttons: {

                    "Confirm": function(){

                        $("#change_password").dialog('open');

                    },

                    "Cancel": function(){

                        $(this).dialog('close');
                        $("#forgot_data").dialog('close');
                        $("#dialog-form").dialog('open');
                        setTimeout(function(){
                                $("#name").focus();

                            }, 800);

                    }
                },
                close: function() {
                    allFields.val('').removeClass('ui-state-error');    
                }
            });

有什么想法吗?,这将是有帮助的。

4

2 回答 2

3

Nalum 的解决方案有效,但有点难看。试试这个:

$('#restore_password').parent().effect("shake", {times: 3}, 80);
于 2012-01-05T18:45:30.587 回答
2

$(...).dialog(...);创建一个没有 id 的新元素。

例如

<div id="testingDiv">...</div>

变成

<div style="..." class="..." tabindex="..." role="dialog" aria-labelledby="ui-dialog-title-testingDiv">
    ...
    <div id="testingDiv">...</div>
    ...
</div>

所以你的代码正在运行。您需要做的是针对对话框 div 例如

$('div[aria-labelledby=ui-dialog-title-testingDiv]').effect("shake", {times: 3}, 80);
于 2010-04-29T15:15:32.513 回答