Api and options

Simpleview.extend(prototypeProperties, [staticProperties])

Used to define view types / constructor functions. Define prototype methods for view via object hash. Static properties are optional.


initialize(options)

Define initialize function in prototype properties if you need to do some logic on view startup. Will receive all arguments from constructor.


events(object | function)

Declare events with object hash or custom function in prototype properties.


            events: {
                'click .selector': 'handler',
                'click {{this.someVariable}}': 'handler', // variable will be injected
                'one:submit form': 'oneSubmit', // handler will run only once
                'resize window': 'onWindowResize',
                'keyup document': 'onDocumentKeyup'
            }
        

delegatedEvents: true | false

Events are delegated to view by default. If you want to bind them directly to elements (to avoid excessive bubbling) set "delegatedEvents" to false.


addView()

Adds view instance to sub view registry. This binding enables effective cleanup of container views.


removeViews()

Removes all registered sub views.


$(selector)

Alias for this.$el.find(selector);


when(resources, [callbackDone, [callbackFail]]) {

Similar to $.when. Resources can be array of deferreds or single deferred. Callbacks are executed with view instance as context.


remove()

Removes view from DOM and does cleanup of all bound events.