如何重新呈现在node.js中的HTML DIV?呈现在、node、js、HTML

2023-09-12 21:16:33 作者:苌吥大の孩纸

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

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

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

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

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

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

  

我有以下选项:

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

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

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

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

解决方案

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

node.js的版本发布

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:

Send list of items from in ajax response. 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.

 
精彩推荐