在创建如下的flowplayer实例之后:
$f("player", "flowplayer.swf", "my-video.flv");
Run Code Online (Sandbox Code Playgroud)
直接删除容器元素时,$("#player").remove()(使用jQuery),
我发现$f("player")还在那里.如何真正删除实例?
<svg width="5cm" height="3cm" viewBox="0 0 500 300">
<path id="path1" d="M100,250 C 100,50 400,50 400,250"
fill="none" stroke="blue" stroke-width="7.06" />
<circle r="17.64" fill="red">
<animateMotion dur="6s" repeatCount="1" rotate="auto" >
<mpath xlink:href="#path1"/>
</animateMotion>
</circle>
</svg>
Run Code Online (Sandbox Code Playgroud)
如果我在普通的html/svg文件中编写svg,它工作正常,圆圈动画正确.但是,如果我通过javascript动态添加圆元素,则添加了圆圈,但它没有动画.怎么了?js代码:
var svg = $("svg"); //use jquery
var circle = document.createElementNS("http://www.w3.org/2000/svg","circle");
circle.setAttribute("r", "5");
circle.setAttribute("fill", "red");
var ani = document.createElementNS("http://www.w3.org/2000/svg","animateMotion");
ani.setAttribute("dur", "26s");
ani.setAttribute("repeatCount", "indefinite");
ani.setAttribute("rotate", "auto");
var mpath = document.createElementNS("http://www.w3.org/2000/svg","mpath");
mpath.setAttribute("xlink:href", "#path1");
ani.appendChild(mpath);
circle.appendChild(ani);
svg.append(circle);
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下代码测试主干集合的更改事件:
var Item = Backbone.Model.extend({});
var ItemCollection = Backbone.Collection.extend({
model: Item,
url: "data.json"
});
var collection = new ItemCollection();
collection.bind("change", function() {cosole.log("collection changed.");});
collection.fetch();
Run Code Online (Sandbox Code Playgroud)
然后我手动更改json文件并再次调用collection.fetch(),没有'change'事件发生,是因为我使用本地json文件或.fetch方法无法触发'change'事件?
我在jstree中使用'contextmenu'和'types'插件,并希望根据'types'定义不同的contextmenu,如下所示:
$("#tree").jstree({
"plugins" : [ "themes", "json_data", "ui", "contextmenu", "types" ],
"themes" : {
"url" : "css/jstree/themes/classic/style.css",
"theme" : "classic",
"icons" : false
},
"json_data" : { "data" : data },
"types": {
"types": {
"leaf": { "contextmenu" : { items : contextMenu } }
}
}
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用,它为所有节点显示相同的上下文菜单,没有像我为'leaf'节点定义的指定的上下文菜单.是因为无法在类型中定义contextmenu吗?那么如何轻松实现这一目标.