Rendering script blocks

a.cheetham at utoronto.ca a.cheetham at utoronto.ca
Wed Feb 4 14:37:48 UTC 2009


Hi, Antranig,

I'm still confused about rendering a script block using the Init Block  
syntax of the renderer.

My template is this:

     <div id="script">
         <script rsf:id="script-test" type="text/javascript">
         </script>
     </div>

My component tree is this:

     var scriptTree = {
         children: [
             {ID: "script-test",
              functionname: "demo.testFunc",
              "arguments": "Hello, I've been rendered!"
             }
         ]
     };

My test function is:

     demo.testFunc = function () {
         alert(arguments[0]);
     };

My call to the renderer is this:

     var scriptTemplate = fluid.selfRender($("#script"), scriptTree);

(all of this can be found in SVN, in  
.../tests/manual/renderer/component-types.*)

 From our brief exchange last night, I had the impression that this  
should result in an actual script block showing up in the final  
rendered markup, containing a call to my function, "demo.testFunc()".  
I was expecting something like this:

     <div id="script">
         <script type="text/javascript">
             demo.testFunc("Hello, I've been rendered!");
         </script>
     </div>

This is not what happens. Instead:
- the script element is not rendered at all
- the test function is actually executed
- only the first letter of the string argument (i.e. H) shows up in the alert

Am I
a) doing something wrong?
b) expecting something wrong?
  or
c) finding bugs in the renderer? :-)

-- 
Anastasia Cheetham                   a.cheetham at utoronto.ca
Software Designer, Fluid Project
Adaptive Technology Resource Centre / University of Toronto