2015-05-20 63 views
2

我想調用Window.open函數上的Action。Window.open調用Cakephp中的動作

我有這對我的看法:

$this->Html->link(
    $this->Html->image('icon-picture.png', array('alt' => 'fotos', 'class'=>'link-fotos', 'onClick' => "window.open('".$this->Html->url(array('controller' => 'Pedidos' ,'action'=>'exibeFotos'))."', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=770, HEIGHT=400')", 'id' => 'dialogFotos')), 
    array('escape' => false)); 

但結果是: Result

我不明白我在做什麼錯。句法?

回答

2

選項數組需要是第三個參數$this->Html->link()。你把它作爲第二個參數傳遞,所以它不能正確渲染"escape=>false"選項...

試試這個:

$this->Html->link(
    $this->Html->image('icon-picture.png', array('alt' => 'fotos', 'class'=>'link-fotos', 'onClick' => "window.open('".$this->Html->url(array('controller' => 'Pedidos' ,'action'=>'exibeFotos'))."', 'Pagina', 'STATUS=NO, TOOLBAR=NO, LOCATION=NO, DIRECTORIES=NO, RESISABLE=NO, SCROLLBARS=YES, TOP=10, LEFT=10, WIDTH=770, HEIGHT=400'); return false;", 'id' => 'dialogFotos')), 
    '#', 
    array('escape' => false) 
); 

這只是增加了一個空的錨鏈接,並增加了return false;到您的onClick事件的末尾,因此在打開新窗口後它不會跟隨鏈接。