简短的问题:我想选择与属性不匹配的所有节点(@type!='x'),但属性也不存在(??).目前,我什么也没收到,因为其他节点根本没有属性.
背景:我有一些XML.请注意,其中一个具有type ="feature",但所有其他都没有'type'attr.
<image type="feature"><description>X</description><url>media/designer_glass_tile_04.jpg</url><height></height><width/></image>
<image><description>Designer Glass 05</description><url>media/designer_glass_tile_05.jpg</url><height></height><width/></image>
<image><description>Designer Glass 06</description><url>media/designer_glass_tile_06.jpg</url><height></height><width/></image>
<image><description>Designer Glass 07</description><url>media/designer_glass_tile_07.jpg</url><height></height><width/></image>
<image><description>Designer Glass 08</description><url>media/designer_glass_tile_08.jpg</url><height></height><width/></image>
Run Code Online (Sandbox Code Playgroud)
和XSL风格:
<div id="gallery">
<div id="feature" >
<xsl:apply-templates select="image[@type='feature']"/>
</div>
<div id="thumbs">
<xsl:apply-templates select="image[@type!='feature']"/>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个包含很多OPTIONAL参数的脚本.一些有相关的价值观.
如:
.script --first 2012-12-25 --last 2012-12-26 --copy --remove
.script --first 2012-12-25
Run Code Online (Sandbox Code Playgroud)
因此以下案例陈述:
for arg in "$@"
do
case $arg in
"--first" )
START_DATE=$arg;;
"--last" )
END_DATE=$arg;;
"--copy" )
COPY=true;;
"--remove" )
REMOVE=true;;
# ... and so on
esac
done
Run Code Online (Sandbox Code Playgroud)
需要增量$arg+1
类型语句来获取以下arg(在某些情况下).
怎么可能?
我也很乐意做一个子串 .script --first2012-12-25 --last2012-12-26
而不知道如何继续前进.
我试图在Backbone应用程序中使用Leaflet.加上它的AMD需要 - 因此它不是页面中的脚本...我相信问题是它无法访问页面DOM.
L.Map需要一个字符串.不是DOM ......
这是一些代码.我甚至尝试延迟几秒钟直到页面呈现.没有成功.
错误是"找不到地图容器"
define([
'jquery',
'underscore',
'backbone',
'collections/Collection',
'text!templates/map/Template.html',
'libs/leaflet-markercluster/leaflet-0.6.4'
], function($, _, Backbone, Collection, Template, L) {
var MapView = Backbone.View.extend({
el : "#sub-page",
template: _.template(Template),
delayedRender: function() {
try {
var map = this.map = new L.Map( '#map_canvas' );
} catch ( err ) {
console.log(err);
}
},
render : function() {
this.$el.html( this.template() );
setTimeout( this.delayedRender, 2 );
}
Run Code Online (Sandbox Code Playgroud)
更深入地研究Leaflet L.Map构造函数会执行document.getElementById,这在AMD骨干应用程序中可能没有意义.
return (typeof id === 'string' ? document.getElementById(id) : id);
Run Code Online (Sandbox Code Playgroud) 在我的大多数情况下,在collection.parse期间会调用model.parse。在某些情况下,不会调用model.parse。
在所有情况下我都需要它。是否可以像在类似选项中那样将其放置在全局位置: Backbone.emulateHTTP = true;
此外,文档还提供了有关model.parse的看似冲突的信息
model.parse(响应,选项)
每当服务器以获取和保存的方式返回模型的数据时,都会调用parse 。
与可能/也许
model.initialize ... 如果将 {parse:true}作为选项传递,则在对模型进行设置之前,将首先通过解析转换属性。