]>
Commit | Line | Data |
---|---|---|
2f01fe57 | 1 | /* |
81bea17a | 2 | Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. |
2f01fe57 AD |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
a089699c AD |
8 | if(!dojo._hasResource["dojo.NodeList-html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
9 | dojo._hasResource["dojo.NodeList-html"] = true; | |
2f01fe57 AD |
10 | dojo.provide("dojo.NodeList-html"); |
11 | dojo.require("dojo.html"); | |
a089699c | 12 | |
81bea17a | 13 | |
a089699c AD |
14 | /*===== |
15 | dojo["NodeList-html"] = { | |
16 | // summary: Adds a chainable html method to dojo.query() / Nodelist instances for setting/replacing node content | |
17 | }; | |
18 | =====*/ | |
19 | ||
20 | dojo.extend(dojo.NodeList, { | |
21 | html: function(content, /* Object? */params){ | |
22 | // summary: | |
23 | // see `dojo.html.set()`. Set the content of all elements of this NodeList | |
24 | // | |
81bea17a AD |
25 | // description: |
26 | // Based around `dojo.html.set()`, set the content of the Elements in a | |
a089699c AD |
27 | // NodeList to the given content (string/node/nodelist), with optional arguments |
28 | // to further tune the set content behavior. | |
29 | // | |
30 | // example: | |
31 | // | dojo.query(".thingList").html("<li dojoType='dojo.dnd.Moveable'>1</li><li dojoType='dojo.dnd.Moveable'>2</li><li dojoType='dojo.dnd.Moveable'>3</li>", | |
81bea17a AD |
32 | // | { |
33 | // | parseContent: true, | |
a089699c AD |
34 | // | onBegin: function(){ |
35 | // | this.content = this.content.replace(/([0-9])/g, this.id + ": $1"); | |
36 | // | this.inherited("onBegin", arguments); | |
37 | // | } | |
38 | // | }).removeClass("notdone").addClass("done"); | |
39 | ||
40 | var dhs = new dojo.html._ContentSetter(params || {}); | |
41 | this.forEach(function(elm){ | |
81bea17a | 42 | dhs.node = elm; |
a089699c AD |
43 | dhs.set(content); |
44 | dhs.tearDown(); | |
45 | }); | |
46 | return this; // dojo.NodeList | |
47 | } | |
2f01fe57 | 48 | }); |
a089699c | 49 | |
2f01fe57 | 50 | } |