如何重新呈现在node.js中的HTML DIV? [英] How to re-render html div in node.js?

查看:239
本文介绍了如何重新呈现在node.js中的HTML DIV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立我的第一个应用程序使用Node.js的。

此应用程序使用防爆preSS作为Web应用程序框架,玉模板引擎。

我要设计这显示从MongoDB数据库中检索的项目列表的屏幕。

起初,同时显示的项数据列表是从控制器发送和格式在玉模板完成的。

不过,我还需要通过Ajax调用来更新产品清单。

我发现很难设计出合适的方法为这个特殊的流程。

  

我有以下选项:

     
      
  1. 发送的产品清单从Ajax响应。
  2.   
  3. 使用JavaScript来渲染UI组件 - 添加CSS类,preparing HTML
  4.   

但是,这种做法是非常脆弱的。也有很多code将在Web浏览器中暴露出来。

我从JSF已经到来重新呈现组件,一个内置功能

能的Node.js,Ajax和重新渲染来凑钱?

解决方案

您应该使用现代的客户端Web开发框架,如AngularJS,这将做到这一切自动完成。

I am building my first app with node.js.

This app uses Express as the web application framework with Jade template engine.

I need to design a screen which displays list of items retrieved from a MongoDB database.

Initially while displaying list of items data is sent from controller and formatting is done in jade template.

However, I also need to update list of items via an ajax call.

I am finding it difficult to design a suitable approach for this particular flow.

I have following option:

  1. Send list of items from in ajax response.
  2. Use javascript to render UI components - adding css class, preparing html.

However this approach is very fragile. Also a lot of code would be exposed in web browser.

I am coming from JSF that has re-render of components, a built-in feature.

Can node.js, ajax and re-render be clubbed together ?

解决方案

You should use modern client-side web development frameworks like AngularJS, which will do all of this automatically.

这篇关于如何重新呈现在node.js中的HTML DIV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆