Nick Nance edited this page Nov 25, 2014 · 3 revisions

addSubView(options)

AddSubView is used to render and add a subview to an parent view. If you need to perform some work after the view is added to the DOM you can implement a 'onShow' function. This will also trigger a 'shown' event.

Parameters:
Name Type Description
options object

An option object with a view and a selector

Source:

close()

Remove all subviews and safely remove this view from the DOM. Implement an 'onClose' function for any additional clean up that is required before removing the view from the DOM. This will trigger a 'closed' event just before removing from the DOM.

Source:

getAttr()

Helper function to return the attribute of a model if the model is assigned

Source:

getSubViewCount()

Retrieve the current number of sub views.

Source:

getView()

Use getView to retrieve the primary subView

Source:

removeSubViewForModel(model)

RemoveSubViewForModel will close the first sub view that has the attched model. As a result a 'closed' event will be fired for the view and it will be removed from the DOM.

Parameters:
Name Type Description
model object

The model associated with the view

Source:

removeSubViews()

Removes all sub-views from a parent

Source:

render()

ViewManager has a default render function that will render if there is a template function defined in the view. If serializeData is implemented its' return value will be passed to the template funcion otherwise this will be passed.

Implement an 'onRender' function to extend the render functionality. It returns 'this' to support chaining. This will trigger a 'rendered' event.

By setting attachToTemplate render will attach the view to the top element of the template. Using this option will remove the default behavior of Backbone that creates all views with a default div tag.

Source:

restoreSubViews()

RestoreSubViews can be used to restore views to the DOM that have been removed as a result of the parent view rerendering

Source:

serializeForm()

Return all the fields and their value of a form as an object

Source:

setView(view, options)

Use setView to replace the entire contents of the view with a new view. this function will also remove all views currently contained within the view. This will trigger a 'shown' event.

Parameters:
Name Type Description
view Backbone.View

The view to use

options object

Set options.emptyDOM to true in cases where the DOM that the view is attached is managed by something other than Backbone

Source:

generated with docme

Getting started

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.