代码之家  ›  专栏  ›  技术社区  ›  Felix

如何将震动效果应用于嵌入窗体的对话框

  •  3
  • Felix  · 技术社区  · 16 年前

    $(“#还原\u密码”).effect(“shake”, {次数:3},80);

    只有表单标记中的字段才起作用,但对话框本身不起作用。

    我的部门

    <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');    
                    }
                });
    

    有什么想法吗?会有帮助的。

    2 回复  |  直到 16 年前
        1
  •  2
  •   Nalum    16 年前

    $(...).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);
    
        2
  •  3
  •   Thomas Hunter II    14 年前

    纳勒姆的解决方案奏效了,但有点难看。试试这个:

    $('#restore_password').parent().effect("shake", {times: 3}, 80);
    
    推荐文章