[SOLVED] Override Onsen UI v1 pushPage function
-
Hello,
I would like to backport this bugfix to my v1 onsen ui apps :
https://github.com/OnsenUI/OnsenUI/pull/1176/commits/b06a6bacca672462e661100ac0e1eda18121aa16I don’t want to change the existing files, so I hoped I could somewhat redefine/override/overload the
NavigatorView.pushPage
function, but I can’t figure out how to do that… Any ideas ?
-
I solved my problem this way:
// Onsen UI v1 dit not get this bugfix to prevent loading the page twice if user taps twice // so we backport it from https://github.com/OnsenUI/OnsenUI/pull/1176/commits/b06a6bacca672462e661100ac0e1eda18121aa16 angular.module('onsen').run(['NavigatorView', function(NavigatorView) { NavigatorView.prototype.pushPage = function(page, options) { if (this._profiling) { console.time('pushPage'); } options = options || {}; if (options.cancelIfRunning && this._isPushing) { return; } if (options && typeof options != 'object') { throw new Error('options must be an object. You supplied ' + options); } if (this._emitPrePushEvent()) { return; } // the backport is just this line... this._isPushing = true; this._doorLock.waitUnlock(function() { this._pushPage(page, options); }.bind(this)); }; }]);