动态生成JavaScript的时候,像这样我得到错误:彩盒调用与动态创建的选择
$(document).ready(function(){
$("#$this->AddURLSegment").colorbox();
}
HTML:
<a href="<?php echo $AddURLSegment;?>?width=500&height=500&iframe=false" id="<?php rcho $AddURLSegment;?>">Add</a>
错误:
uncaught exception: Syntax error, unrecognized expression: #
: 上添加第一个点击
第二次:
ab.html(a.close).show is not a function
uncaught exception: Syntax error, unrecognized expression: #
和2个叠加打开,一个好,一个坏了。
!当我硬编码选择器(ID名称)像这样....,它的作品。
$("#add").colorbox();
这是什么锣!
编辑:
林在silverstripe CMS
的JavaScript(noconflict)在控制器初始化::生成()
Requirements::customScript('
$j(document).ready(function(){
$j("#'.$this->AddURLSegment.'").colorbox();
});
');
html的东西是在查看这样做。
* SilverStripe基于MVC范例。
你注入JavaScript与JavaScript?发布更多的'$(“#$ this'段的周边代码 – 2011-03-14 22:04:28