https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/

https://api.jqueryui.com/jquery.widget/#method-_super

https://johnresig.com/blog/simple-javascript-inheritance/

To make the parent's methods available, the widget factory provides two methods - _super() and _superApply().

Using _super() and _superApply() to Access Parents

https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/#using-_super-and-_superapply-to-access-parents

_super() and _superApply() invoke methods of the same name in the parent widget. Refer to the following example. Like the previous one, this example also overrides the open() method to log "open". However, this time _super() is run to invoke dialog's open() and open the dialog.

$.widget( "custom.superDialog", $.ui.dialog, {
open: function() {
console.log( "open" ); // Invoke the parent widget's open().
return this._super();
}
}); $( "<div>" ).superDialog();
proxiedPrototype[ prop ] = (function() {
var _super = function() {
return base.prototype[ prop ].apply( this, arguments );
},
_superApply = function( args ) {
return base.prototype[ prop ].apply( this, args );
};
return function() {
var __super = this._super,
__superApply = this._superApply,
returnValue; this._super = _super;
this._superApply = _superApply; returnValue = value.apply( this, arguments ); this._super = __super;
this._superApply = __superApply; return returnValue;
};
})();

jquery ui widget 源码分析

 //在传入的ui原型中有方法调用this._super 和this.__superApply会调用到base上(最基类上)的方法
127 $.each(prototype, function(prop, value) {
128 //如果val不是function 则直接给对象赋值字符串
129 if (!$.isFunction(value)) {
130 proxiedPrototype[prop] = value;
131 return;
132 }
133 //如果val是function
134 proxiedPrototype[prop] = (function() {
135 //两种调用父类函数的方法
136 var _super = function() {
137 //将当期实例调用父类的方法
138 return base.prototype[prop].apply(this, arguments);
139 },
140 _superApply = function(args) {
141 return base.prototype[prop].apply(this, args);
142 };
143 return function() {
144 var __super = this._super,
145 __superApply = this._superApply,
146 returnValue;
147 // console.log(prop, value,this,this._super,'===')
148 // debugger;
149 //在这里调用父类的函数
150 this._super = _super;
151 this._superApply = _superApply;
152
153 returnValue = value.apply(this, arguments);
154
155 this._super = __super;
156 this._superApply = __superApply;
157 // console.log(this,value,returnValue,prop,'===')
158 return returnValue;
159 };
160 })();
161 });

this._super()的更多相关文章

  1. Java修炼——继承_super父类对象的引用

    Super是指直接父类对象的引用,可以通过super来访问父类中被子类覆盖的方法和属性. 当你调用子类的构造方法时,系统会默认给你先调用父类的构造方法,然后才会调用子类的构造方法. package c ...

  2. HTML5 学习总结(四)——canvas绘图、WebGL、SVG

    一.Canvas canvas是HTML5中新增一个HTML5标签与操作canvas的javascript API,它可以实现在网页中完成动态的2D与3D图像技术.<canvas> 标记和 ...

  3. TypeScript之面向对象初体验

    1.安装nodejs和vscode: nodejs : https://nodejs.org/en/ Visual Studio Code :  https://www.visualstudio.co ...

  4. 基于Nuclear的Web组件-Todo的十一种写法

    刀耕火种 刀耕火种是新石器时代残留的农业经营方式.又称迁移农业,为原始生荒耕作制. var TodoApp = Nuclear.create({ add: function (evt) { evt.p ...

  5. AlloyRenderingEngine燃烧的进度条

    写在前面 Github: https://github.com/AlloyTeam/AlloyGameEngine HTML 5新增了progress标签,那么再去使用AlloyRenderingEn ...

  6. AlloyRenderingEngine文本框组件

    写在前面 Github: https://github.com/AlloyTeam/AlloyGameEngine 在dom元素里,自带了input标签,设置其type为text,它就是一个文本框. ...

  7. 强大的observejs

    写在前面 各大MVVM框架的双向绑定太难以观察,很难直观地从业务代码里知道发生了什么,我不是双向绑定的反对者,只是认为双向绑定不应该糅合进底层框架,而应该出现在业务代码中,或者是业务和框架之间的代码上 ...

  8. AlloyRenderingEngine继承

    写在前面 不读文章,只对代码感兴趣可以直接跳转到这里 https://github.com/AlloyTeam/AlloyGameEngine然后star一下,多谢支持:). 前几天发了篇向ES6靠齐 ...

  9. 移动开发框架剖析(二) Hammer专业的手势控制

    浏览器底层并没有给元素提供类似,单击,双击,滑动,拖动这些直接可以用的控制接口,一切的手势动作都只能通过模拟出来.移动端浏览器唯一给我们提供的就只是mousedown -> mousemove ...

随机推荐

  1. SQL查询结果列拼接成逗号分隔的字符串:group_concat

    转自:SQL查询结果列拼接成逗号分隔的字符串 背景:做SQL查询时会经常需要,把查询的结果拼接成一个字符串. 解决方法: 通过 group_concat 函数 拼接的结果很长,导致拼接结果显示不全,可 ...

  2. Diango路由映射FBV和CBV

    django中请求处理方式有2种:FBV(function base views) 和 CBV(class base views),换言之就是一种用函数处理请求,一种用类处理请求. FBV # url ...

  3. http-proxy-middleware

    概述 这是设置代理的神器,webpack的devServer.proxy就是使用了非常强大的 http-proxy-middleware 包.Node.js代理很简单. 轻松配置代理中间件进行连接,发 ...

  4. 2019 Multi-University Training Contest 2 - 1011 - Keen On Everything But Triangle - 线段树

    http://acm.hdu.edu.cn/showproblem.php?pid=6601 首先要贪心地想,题目要最长的边长,那么要怎么构造呢?在一段连续的区间里面,一定是拿出最长的三根出来比,这样 ...

  5. 动态规划(股票交易)---只能进行 k 次的股票交易

    只能进行 k 次的股票交易 188. Best Time to Buy and Sell Stock IV (Hard) 题目描述:   只能进行K次股票交易,求能获得的最大利润 思路分析:   和只 ...

  6. 剑指offer-链表中环的入口结点-链表-python ***

    题目描述 给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null. 思路 第一步,用两个快慢指针找环中相汇点.分别用slow, fast指向链表头部,slow每次走一步,fast每次 ...

  7. Qt读写Json

    Qt操作Json 1.QJsonDocument 1.详细说明 QJsonDocument类提供了读写JSON文档的方法. QJsonDocument是一个封装了完整JSON文档的类,可以从基于UTF ...

  8. (新手入门,学习笔记)通过NPM进行Vue.js的安装

    NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,本文只介绍如何通过NPM进行安装Vue.js NodeJS官方网站:http://nodejs.cn/downlo ...

  9. mysql分组函数及其用例

    功能:用作统计使用,又称为聚合函数或统计函数或组函数 分类:sum 求和.avg 平均值.max 最大值 .min 最小值 .count 计算个数 特点: 1.sum.avg一般用于处理数值型,max ...

  10. SPSS Statistics 多个版本的下载安装激活步骤

    SPSS 23:https://www.cnblogs.com/coco56/p/11648386.html SPSS25:https://www.cnblogs.com/coco56/p/11648 ...