如何从'。$ 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;
});
答案 0 :(得分:0)
您可以在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;
});