admin管理员组

文章数量:1278823

i want create one div ( basically it will containt listbox) , and i want to use the div in different pages,

which is the best option to use in duarandal.js?

Composition

/

Widget

/

i want create one div ( basically it will containt listbox) , and i want to use the div in different pages,

which is the best option to use in duarandal.js?

Composition

http://durandaljs./documentation/Using-Composition/

Widget

http://durandaljs./documentation/Creating-A-Widget/

Share Improve this question edited Aug 19, 2013 at 14:41 patel asked Aug 19, 2013 at 14:34 patelpatel 6355 gold badges24 silver badges40 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

In general, think of using the pose binding as templates, and widgets as user controls

There's not quite enough information in your question for me to offer a suggestion on which is the right choice for you, but I'll provide some parison for the two below, which should make it easier for you to choose.


Durandal's pose binding can be used to render, or inject, one view as part of another. For example, a menu.html may be defined that can be used to display menu items. This is similar to the concept of a jQuery template, or a "partial view" in ASP.Net MVC. A posed view can either use the parent's view model as its data source, or it can have its own view model.

The pose binding is most useful when you have a view and/or view model that can be used as is in multiple places.

Durandal's widgets, on the other hand, use position internally, but are designed to abstract the "parts" of the widget so that one widget can be configured differently on each view where it is rendered. A widget can have parts, and these parts can be exposed through the widget interface.

Durandal widgets are most useful when you want to create some functionality that can be used across multiple views, but the implementations may differ.

本文标签: javascriptDurandaljscomposition vs widgetStack Overflow