Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

MobileWeb: Using apply() to run an event handler in a specific scope

$
0
0

On iOS, I can use the following function to set scope for an event handler:

var oxi = {};
oxi.bind = function(scope, fn) {
        return function() {
            fn.apply(scope, arguments);
        };
};
 
// Setting event handler in "this" scope:
 
Ti.App.addEventListener('CUSTOM:MyCustomEvent',oxi.bind(this,myDefinedFunction));
 
// Removing event handler 
 
Ti.App.removeEventListener('CUSTOM:MyCustomEvent',oxi.bind(this,myDefinedFunction));
However, on MobileWeb the event handler is not removed - so it seems the bind-method on the addEventListener and removeEventListener aren't refering to the same function anymore.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>