如何从“.$user”CONTENT“”加载内容。“在文本字段中?如果有任何解决方案,请帮助我
谢谢
$('#add-max').ready(function(){
$.gritter.add({
// (string | mandatory) the heading of the notification
title: 'This is a notice with a max of 3 on screen at one time!',
// (string | mandatory) the text inside the notification
text: 'HERE ',
// (string | optional) the image to display on the left
image: 'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png',
// (bool | optional) if you want it to fade out on its own or just sit there
sticky: false,
// (function) before the gritter notice is opened
before_open: function(){
if($('.gritter-item-wrapper').length == 3)
{
// Returning false prevents a new gritter from opening
return false;
}
}
});
return false;
});发布于 2014-03-07 06:07:02
您将在PHP视图/输出文件中执行类似以下操作:
<html>
<head>
</head>
<body>
<!-- content -->
<!-- assign js vars from PHP here -->
<script type="text/javascript">
var userContent = <?php echo $user['Content']; ?>
</script>
<!-- load your other custom JS files after. Best practice is to put these at the bottom of <body> -->
<script type="text/javascript" src="/your/javascript/file/here.js"></script>
</body>
</html>基本上,您可以在任意javascript标记块中声明一个javascript变量,并将PHP数据回显到该变量中。
然后,所有后续脚本都可以访问该变量,您可以随心所欲地使用它。
因此,要使用jQuery代码,需要将前面定义的userContent变量作为text字段的值。
$('#add-max').ready(function(){
$.gritter.add({
// (string | mandatory) the heading of the notification
title: 'This is a notice with a max of 3 on screen at one time!',
// (string | mandatory) the text inside the notification
text: userContent,
// (string | optional) the image to display on the left
image: 'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png',
// (bool | optional) if you want it to fade out on its own or just sit there
sticky: false,
// (function) before the gritter notice is opened
before_open: function(){
if($('.gritter-item-wrapper').length == 3)
{
// Returning false prevents a new gritter from opening
return false;
}
}
});
return false;
});https://stackoverflow.com/questions/22236017
复制相似问题