source: Dev/trunk/src/client/dojo/NodeList-html.js @ 527

Last change on this file since 527 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.7 KB
Line 
1define(["./query", "./_base/lang", "./html"], function(query, lang, html){
2
3// module:
4//              dojo/NodeList-html
5
6/*=====
7return function(){
8        // summary:
9        //              Adds a chainable html method to dojo/query() / NodeList instances for setting/replacing node content
10};
11=====*/
12
13var NodeList = query.NodeList;
14
15
16lang.extend(NodeList, {
17        html: function(/* String|DomNode|NodeList? */ content, /* Object? */params){
18                // summary:
19                //              see `dojo/html.set()`. Set the content of all elements of this NodeList
20                //
21                // content:
22                //              An html string, node or enumerable list of nodes for insertion into the dom
23                //
24                // params:
25                //              Optional flags/properties to configure the content-setting. See dojo/html._ContentSetter
26                //
27                // description:
28                //              Based around `dojo/html.set()`, set the content of the Elements in a
29                //              NodeList to the given content (string/node/nodelist), with optional arguments
30                //              to further tune the set content behavior.
31                //
32                // example:
33                //      |       require(["dojo/query", "dojo/NodeList-html"
34                //      |       ], function(query){
35                //      |               query(".thingList").html("<li data-dojo-type='dojo/dnd/Moveable'>1</li><li data-dojo-type='dojo/dnd/Moveable'>2</li><li data-dojo-type='dojo/dnd/Moveable'>3</li>",
36                //      |               {
37                //      |                       parseContent: true,
38                //      |                       onBegin: function(){
39                //      |                               this.content = this.content.replace(/([0-9])/g, this.id + ": $1");
40                //      |                               this.inherited("onBegin", arguments);
41                //      |                       }
42                //      |               }).removeClass("notdone").addClass("done");
43                //      |       });
44
45                var dhs = new html._ContentSetter(params || {});
46                this.forEach(function(elm){
47                        dhs.node = elm;
48                        dhs.set(content);
49                        dhs.tearDown();
50                });
51                return this; // dojo/NodeList
52        }
53});
54
55return NodeList;
56});
Note: See TracBrowser for help on using the repository browser.