I'm trying to call a function by clicking an HTML link on a surface. This doesn't work as intended:
define(function(require, exports, module) {
var Engine = require("famous/core/Engine");
var Surface = require("famous/core/Surface");
var mainContext = Engine.createContext();
var surf = new Surface({
size: [100, 50],
content: '<a href="#" onclick="test()">Click me</a>',
properties: {
backgroundColor: '#00FF00'
}
});
function test(){
alert('Test!');
}
mainContext.add(surf);
});
var test = function(){
alert('Wrong call...');
}
I want it to call the first "test()" function, but all it does is call the outer one.
To get it, I tried something like this:
var testObject = define(function(require, exports, module) {
(...)
var surf = new Surface({
size: [100, 50],
content: '<a href="#" onclick="testObject.test()">Click me</a>',
properties: {
backgroundColor: '#00FF00'
}
});
(...)
};
However that didn't work either. Any ideas on how to get it to call the right function?