我有这段代码:
function someFunction () {
alert('fired!')
}
var options = [
{selector: 'footer', offset: 50, callback: 'someFunction()' },
];
Materialize.scrollFire(options);
我收到错误Uncaught ReferenceError: someFunction is not defined
我明白为什么会这样,但我无法得到,我怎么能触发someFunction呢?
PS。如果我将'someFunction()'
更改为alert('fired!')
,则会发出警报。
答案 0 :(得分:2)
只需将其更改为对函数的引用:
var options = [
{
...
callback: someFunction
];