是否可以使用Dojo完成?这是JQuery代码:
$(document).ready(function() {
$(document).on("click", "a.cssPauseAll[historyID]", function() {
var historyID = $(this).attr("historyID");
$(document).find("[itemHistoryID=" + historyID + "]").each(function() {
alert($(this).attr("ContentID"));
});
});
});
答案 0 :(得分:2)
这取决于您是使用baseless还是遗留Dojo。我在这个jsFiddle中实现了两个:http://jsfiddle.net/phusick/PxgZE/
require([
"dojo/on",
"dojo/query",
"dojo/dom-attr",
"dojo/string",
"dojo/domReady!"
], function(
on,
query,
attr,
string
) {
on(document, "a.cssPauseAll:click", function(event) {
var historyId = attr.get(event.target, "historyID");
query(string.substitute("[itemHistoryID=${0}]", [historyId])).forEach(function(node) {
alert("Baseless Dojo: " + attr.get(node, "ContentID"));
});
})
});
dojo.ready(function() {
dojo.connect(document, "a.cssPauseAll:click", function(event) {
var historyId = dojo.attr(event.target, "historyID");
dojo.query("[itemHistoryID=" + historyId + "]").forEach(function(node) {
alert("Legacy Dojo: " + dojo.attr(node, "ContentID"));
});
});
});