【问题标题】:Create bootstrap alert in push notification page using nodejs使用 nodejs 在推送通知页面中创建引导警报
【发布时间】:2017-10-12 04:24:15
【问题描述】:

我有一个使用 NodeJS 自动从 MySQL 显示信息的页面。如何使文本用户名或描述显示为引导警报,例如“alert alert-info”?

<time></time>
<div id="container">Loading ...</div>
<script src="socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
// create a new websocket
var socket = io.connect('http://localhost:8000');
// on message received we print all the data inside the #container div
socket.on('notification', function (data) {
var usersList = "<dl>";
$.each(data.users,function(index,user){
		usersList += "<dt>" + user.user_name + "</dt>\n" +
								 "<dd>" + user.user_description + "\n" + "</dd>";
});
usersList += "</dl>";
$('#container').html(usersList);

$('time').html('Last Update:' + data.time);
});

</script>

【问题讨论】:

    标签: javascript jquery node.js twitter-bootstrap


    【解决方案1】:

    我会使用预定义(隐藏)模式,将占位符替换为动态数据,并在通知时触发显示

    类似(通知函数体中的伪代码)

     $("#myModal .modal-body").html('my content');
     $("#myModal").modal();
    

    (以编程方式触发的引导模式示例)

    https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_ref_js_modal_js&stacked=h

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多