📜  BackboneJS-视图

📅  最后修改于: 2020-10-27 03:41:47             🧑  作者: Mango


视图用于反映“数据模型的外观”。它们向用户表示模型的数据。它们为用户提供了模型数据呈现的思路。它处理用户输入事件,绑定事件和方法,渲染模型或集合并与用户进行交互。

下表列出了可用于操作BackboneJS-Views的方法

S.No. Methods & Description
1 extend

It extends the Backbone.View class to create a custom view class.

2 initialize

It instantiates the view by using the new keyword.

3 el

It defines which element to be used as the view reference.

4 $el

It represents the jQuery object for the view’s element.

5 setElement

It specifies the existing DOM element to a different DOM element.

6 attributes

They can be used as DOM element attributes on the view class.

7 $(jQuery)

It is used as a selector that contains the $ function and runs queries within the view’s element.

8 template

While rendering the view, template creates reusable copies of markup and provides access to instance data.

9 render

It contains the logic for rendering a template.

10 remove

Removes a view from the DOM.

11 delegateEvents

Binds elements to the specified DOM elements with callback methods to handle events.

12 undelegateEvents

It removes delegate events from the view.