source: Dev/branches/rest-dojo-ui/client/dojo/NodeList-html.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 1.6 KB
Line 
1define(["./query", "./_base/lang", "./html"], function(query, lang, html) {
2        // module:
3        //              dojo/NodeList-html
4        // summary:
5        //              TODOC
6
7var NodeList = query.NodeList;
8
9/*=====
10dojo["NodeList-html"] = {
11        // summary: Adds a chainable html method to dojo.query() / Nodelist instances for setting/replacing node content
12};
13
14// doc helper aliases:
15NodeList = dojo.NodeList;
16=====*/
17
18lang.extend(NodeList, {
19        html: function(/* String|DomNode|NodeList? */ content, /* Object? */params){
20                //      summary:
21                //              see `dojo.html.set()`. Set the content of all elements of this NodeList
22                //
23                //      content:
24                //              An html string, node or enumerable list of nodes for insertion into the dom
25                //
26                //      params:
27                //              Optional flags/properties to configure the content-setting. See dojo.html._ContentSetter
28                //
29                //      description:
30                //              Based around `dojo.html.set()`, set the content of the Elements in a
31                //              NodeList to the given content (string/node/nodelist), with optional arguments
32                //              to further tune the set content behavior.
33                //
34                //      example:
35                //      | 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>",
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                var dhs = new html._ContentSetter(params || {});
45                this.forEach(function(elm){
46                        dhs.node = elm;
47                        dhs.set(content);
48                        dhs.tearDown();
49                });
50                return this; // dojo.NodeList
51        }
52});
53
54return NodeList;
55});
Note: See TracBrowser for help on using the repository browser.