<i id='c8SBV'><tr id='c8SBV'><dt id='c8SBV'><q id='c8SBV'><span id='c8SBV'><b id='c8SBV'><form id='c8SBV'><ins id='c8SBV'></ins><ul id='c8SBV'></ul><sub id='c8SBV'></sub></form><legend id='c8SBV'></legend><bdo id='c8SBV'><pre id='c8SBV'><center id='c8SBV'></center></pre></bdo></b><th id='c8SBV'></th></span></q></dt></tr></i><div id='c8SBV'><tfoot id='c8SBV'></tfoot><dl id='c8SBV'><fieldset id='c8SBV'></fieldset></dl></div>
    1. <small id='c8SBV'></small><noframes id='c8SBV'>

    2. <legend id='c8SBV'><style id='c8SBV'><dir id='c8SBV'><q id='c8SBV'></q></dir></style></legend>

        <bdo id='c8SBV'></bdo><ul id='c8SBV'></ul>
    3. <tfoot id='c8SBV'></tfoot>
    4. 使用重新定义父方法在 Jquery UI 中扩展小部件

      时间:2023-09-07
          • <bdo id='OJnur'></bdo><ul id='OJnur'></ul>

            • <legend id='OJnur'><style id='OJnur'><dir id='OJnur'><q id='OJnur'></q></dir></style></legend>

              <small id='OJnur'></small><noframes id='OJnur'>

              <i id='OJnur'><tr id='OJnur'><dt id='OJnur'><q id='OJnur'><span id='OJnur'><b id='OJnur'><form id='OJnur'><ins id='OJnur'></ins><ul id='OJnur'></ul><sub id='OJnur'></sub></form><legend id='OJnur'></legend><bdo id='OJnur'><pre id='OJnur'><center id='OJnur'></center></pre></bdo></b><th id='OJnur'></th></span></q></dt></tr></i><div id='OJnur'><tfoot id='OJnur'></tfoot><dl id='OJnur'><fieldset id='OJnur'></fieldset></dl></div>
              <tfoot id='OJnur'></tfoot>
                <tbody id='OJnur'></tbody>

                本文介绍了使用重新定义父方法在 Jquery UI 中扩展小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我尝试根据 documentation(UI 版本 1.8.16)扩展 UI 对话框:

                I try to extend UI dialog according to documentation (UI version 1.8.16):

                (function($) {
                    $.widget('ui.mydialog', $.extend(true, $.ui.dialog.prototype, {
                        _create: function() {
                            return $.Widget.prototype._create.apply(this, arguments);
                        }
                    }));
                })(jQuery);
                
                $(function() {
                    $('div#dialog').mydialog();
                });
                

                执行此代码会导致 JS 错误:this.uiDialog is undefined".

                Executing of this code causes JS error: "this.uiDialog is undefined".

                如果尝试重写 _init() 方法没有错误,但父方法调用无效.

                And if try to override the _init() method there are no errors, but parent method call takes no effect.

                我很困惑..哪种方式可以合法扩展例如放一些自定义初始化代码?

                I'm confused.. Which way is legal to extending for e.g. put some custom initialize code?

                推荐答案

                我认为这篇文章会解决你的问题:从 jQuery UI 对话框继承并调用被覆盖的方法.

                I think this post would solve your question: Inherit from jQuery UI dialog and call overridden method.

                简而言之,如果你想构建一个继承 jQuery UI Dialog 的小部件,你可以这样做:

                In short, if you want to build a widget inheriting jQuery UI Dialog, you can do this:

                (function($) {
                    $.widget("ui.mydialog", $.ui.dialog, {
                        _create: function() {
                            $.ui.dialog.prototype._create.call(this);
                        }
                    });
                
                })(jQuery);
                

                查看实际操作:http://jsfiddle.net/william/RELxP/.

                本教程将启发你:http://wiki.jqueryui.com/w/page/12138135/Widget%20factory.简而言之,$.Widget 是基础小部件对象.即使它有一个 _create 函数,默认情况下它什么也不做,将初始化代码留给子类.看看这个更新的例子:http://jsfiddle.net/william/RELxP/1.

                This tutorial will enlighten you: http://wiki.jqueryui.com/w/page/12138135/Widget%20factory. In short, $.Widget is the base widget object. Even though it has a _create function, it by default does nothing, leaving the initialisation code to the subclass. Take a look at this updated example: http://jsfiddle.net/william/RELxP/1.

                这篇关于使用重新定义父方法在 Jquery UI 中扩展小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:呈现后以编程方式应用 jquery (mobile) css 类 下一篇:有没有办法在一个页面上加载多个谷歌翻译小部件

                相关文章

                  <small id='cnp8V'></small><noframes id='cnp8V'>

                1. <i id='cnp8V'><tr id='cnp8V'><dt id='cnp8V'><q id='cnp8V'><span id='cnp8V'><b id='cnp8V'><form id='cnp8V'><ins id='cnp8V'></ins><ul id='cnp8V'></ul><sub id='cnp8V'></sub></form><legend id='cnp8V'></legend><bdo id='cnp8V'><pre id='cnp8V'><center id='cnp8V'></center></pre></bdo></b><th id='cnp8V'></th></span></q></dt></tr></i><div id='cnp8V'><tfoot id='cnp8V'></tfoot><dl id='cnp8V'><fieldset id='cnp8V'></fieldset></dl></div>

                  <tfoot id='cnp8V'></tfoot>
                  1. <legend id='cnp8V'><style id='cnp8V'><dir id='cnp8V'><q id='cnp8V'></q></dir></style></legend>

                      <bdo id='cnp8V'></bdo><ul id='cnp8V'></ul>