0

是否可以使用 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"));
            });

        });

    });​
4

1 回答 1

2

这取决于您使用的是基础 Dojo 还是旧版 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"));
        });
    });
});
于 2012-10-11T13:35:40.397 回答