开发者

Zend Framework autocomplete jQuery UI Form Helper problem

I'm trying to use the JQuery autocomplete view helper in zend framework, here my simple view code:

echo $this->autoComplete("brand",
                            "",
                            array(
                            'source' => $this->url(
                                        array('controller' => 'json', 'action' => 'brands'),
                                        'default',
                                        true),
                            'minLength' => '2'
));

Here the js output code:

<script type="text/javascript"> 
//<!--
$(document).ready(function() {
$("#brand").autocomplete({"source":"\/json\/brands","minLength":"2"});
});
//-->
</script>

ZF escape the source url ("/json/brands"). I found this on the official documentation:

The data is casted to JSON, so make sure to use the Zend_Json_Expr class to mark executable javascript as safe.

But I need to put the source ur开发者_开发技巧l as parameter. How can I do it?


I found it! I have to put the url in a new Zend_Json_Expr():

echo $this->autoComplete("brand",
                            "",
                            array(
                            'source' => new Zend_Json_Expr('"'.$this->url(
                                        array('controller' => 'json', 'action' => 'brands'),
                                        'default',
                                        true).'"'),
                            'minLength' => '2'
));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜