我會有從Zend_Form
產生了一些HTML數據。錯誤:未結束的字符串
我想將它附加到div#wrapper
元素,但我的嘗試引發了一個錯誤:Unterminated string literal
。
我應該怎麼做才能解決它?
注:還好大家看起來像假設我忘了把PHP的標籤在我的代碼,但事實並非如此。這裏是我的「真實」代碼
<?php
class Admin_Elements_Dialog {
private $_name;
private $_title;
private $_action;
private $_button = null;
private $_content;
private $_options = array();
public function __construct($options) {
$this->_options = $options;
}
public function setName($name) {
$this->_name = $name;
return $this;
}
public function setTitle($title) {
$this->_title = $title;
return $this;
}
public function setAction($action) {
$this->_action = $action;
return $this;
}
public function setOpener($button) {
if ($button instanceof Admin_Elements_Buttons)
$this->_button = $button;
return $this;
}
public function setContent($content) {
$this->_content = $content;
return $this;
}
public function renderScript() {
$html = array();
$html[] = '$(document).ready(function() {
$("body").append(\'<div id="' . $this->_name . '" title="' . $this->_title . '" class="ui-helper-hidden">' . $this->_content . '</div>\');
var dialog = $("#' . $this->_name . '").dialog(' . Zend_Json::encode($this->_options, false, array('enableJsonExprFinder' => true)) . ');
$("#' . $this->_button->getId() . '").click(function() {
$("#' . $this->_name . '").dialog("open");
return false;
});
});';
$html[] = '';
return join($html, PHP_EOL);
}
}
?>
它確實是這樣他混合PHP和JavaScript .. – ThiefMaster 2011-06-09 13:43:11
@Tomalak:對不起,我的英語不好,和平甘 – brian 2011-06-09 14:17:14
敏感性絃樂器儘管如此,如果你解決你的問題發佈的解決方案作爲一個答案,而不是一個編輯。 – 2011-06-09 14:20:32