Browse Source

ZF-10311: Fixed Zend_Json_Expr support for Zend_Dojo dijits

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23367 44c647ce-9c0f-0410-b52a-842ac1e357ba
bittarman 15 years ago
parent
commit
a0b36da435

+ 1 - 1
library/Zend/Dojo/View/Helper/Dojo/Container.php

@@ -845,7 +845,7 @@ class Zend_Dojo_View_Helper_Dojo_Container
     public function dijitsToJson()
     public function dijitsToJson()
     {
     {
         require_once 'Zend/Json.php';
         require_once 'Zend/Json.php';
-        return Zend_Json::encode($this->getDijits());
+        return Zend_Json::encode($this->getDijits(), false, array('enableJsonExprFinder' => true));
     }
     }
 
 
     /**
     /**

+ 10 - 0
tests/Zend/Dojo/View/Helper/DojoTest.php

@@ -902,6 +902,16 @@ function() {
         $this->assertFalse($helper->registerDojoStylesheet());
         $this->assertFalse($helper->registerDojoStylesheet());
     }
     }
 
 
+    public function testJsonExpressionRenders()
+    {
+        $this->helper->addDijit('foo',
+                array('dojoType' => 'dijit.form.TextBox',
+                      'onChange' => new Zend_Json_Expr('function(){alert(\'foo\');}'),
+                      ));
+        $output = $this->helper->dijitsToJson();
+        $this->assertRegexp('#(function\\(\\){alert\\(\'foo\'\\);})#', $output);
+    }
+
     public function setupDojo()
     public function setupDojo()
     {
     {
         $this->helper->requireModule('dijit.layout.ContentPane')
         $this->helper->requireModule('dijit.layout.ContentPane')