我尝试新的数据推入一个jQuery函数调用filter.js(https://github.com/jiren/filter.js)将内容推送到fliter.js(jQuery的过滤脚本)
问题是,我无法弄清楚如何数组addData应该看起来像。
下面是脚本演示: http://jiren.github.io/filter.js/stream.html
这里就是它从开始获取JSON: /examples/data/top_movies_data.json
关于这个功能的唯一文件说:
Add more data to existing filter
If you are streaming json data using ajax then you can add data like this
fJS.addData(data)
Here fJS is Filter.js object and data is json records.
我正在尝试使用此代码制作一个新框,它回显的“添加”,但没有框被添加,它不打印“添加”
<button id="add">ADD</button>
<script>
$("#add").click(function() {
alert("add");
var myNewBox = '[{"name":"Woho","outline":"Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.","rating":"9.3","director":"Frank Darabont","year":"1994","stars":["Tim Robbins","Morgan Freeman","Bob Gunton"],"runtime":"142","genre":["Crime","Drama"],"certificate":"R"}]';
fJS.addData(myNewBox);
alert("added");
});
</script>
控制台给我这个错误:的ReferenceError:FJS没有定义
我会很高兴,如果有人可以帮助我,我应该如何改变我的功能,可以添加数据。
非常感谢提前!
我不明白你在哪里定义'fJS'? – Elen
我相信它是在/ example /文件夹中的filter.js中定义的:https://github.com/jiren/filter.js/blob/master/examples/filterjs.js –
不,它是函数。但你必须把它分配给一个变量或元素。文档是相当差的寿...它被定义为'var fJS = filterInit('mustache');' – Elen