title: Passing function object references as serialized json
body: <p>I have written some widgets using the jquery widget factory. Normally, I pass options and callback references using the widget constructor in a JavaScript code block. </p>
  
  <p>Now I want to use the widgets in auto generated html pages and pass options to them without using JavaScript blocks. I am specifying the options in embedded json which a common JavaScript code block parses and passes it on to the widget.</p>
  
  <pre><code>&lt;div id="search_widget"&gt;
      &lt;script type="application/json"&gt;
      {
          "search": {
              "search_string": "text to be searched",
              "callback": "a function object in an outer scope"
          }
      }
      &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How do I pass the function objects preserving their scope to the widgets in json format ?
  The widget will then call the function specified when a condition is met.</p>
  
  <p>Thanks for your help.</p>