注: この質問は、古いバージョンの Mozilla x-tag に基づいています。
私のプロジェクトではMozilla x-tagを使用しています。x-master というタグを作成しました。index.html でこれらのタグを 2 つ取得しました。
<div id="page-one" data-role="page">
<x-master id="x-one" data-src="source1"></x-master>
</div>
<div id="page-two" data-role="page">
<x-master id="x-two" data-src="source2"></x-master>
</div>
xtag コンポーネントは次のようになります。
(function(window, document, undefined) {
var jsonurl;
xtag.register('x-master', {
onCreate : function() {
jsonurl = this.getAttribute('data-src');
},
methods : {
getContent : function(){
$.getJSON(jsonurl, function(data){ console.log(jsonurl); };
}
}
})(this, this.document);
私の問題: id x-one のメソッド getContent を呼び出すと、次のように出力されます: source2. どうすればこの動作を防ぐことができますか?