-2
我在项目中集成了星级功能(https://github.com/nashio/star-rating-svg)。
我打电话的脚本在PHP循环是这样的:
while($row = $result->fetch_assoc()){
//the rating div
echo '<div class="my-rating'.$row['id'].' jq-stars"></div>';
//construct instance of star-rating
echo "<script>
$(function() {
$(\".my-rating".$row['id']."\").starRating({
starSize: 25,
//THE NEXT LINE CONTAINS THE PROBLEMATIC $-sign:
callback: function(currentRating, $el){
alert('rated ', currentRating);
}
});
</script>";
}
由于PHP是在式解读$($ EL)即使是在不间断的回声标签,脚本坏了。即使我需要在外观中调用脚本,我仍然可以使用回调函数做些什么?
感谢您的努力,时间和帮助!
把它包在'单quote' – Rayon
你甚至都不需要一个$埃尔变量,你的回调函数不会使用它。只是删除它,是没用的。 –