Giter Club home page Giter Club logo

backbonecleanup's Introduction

Backbone.Cleanup

Backbone cleanup plugin for views

Getting Started

This is a Backbone clean plugin. After integrating this plugin with your application you can stop thinking about how and where to clean your views.

This Implementation Relies on the following libraries:

More information can be found here: http://www.webdeveasy.com/backbone-cleanup

Usage

  1. Extend your router from Backbone.CleanupRouter.

  2. Each route in your router has a main view instance which is going to be displayed. After rendering this view, call this.markCurrentView(view); in order to let the plugin know which view is currently displayed.
    Router for example:

    var router = Backbone.CleanupRouter.extend({
        routes: {
            'page-a': 'pageA'
        },
        pageA: function() {
            var view = // create a view for page A
            this.markCurrentView(view);
        }
    });
    
  3. Extend your views from Backbone.CleanupView.

  4. Inside your view, each nested view must be marked with this.setNestedView(view);

  5. Now all you have to do is to define a 'cleanup()' method in views you want to clean. View for example:

    var view = Backbone.CleanupView.extend({
        render: function() {
            // Render current view
            var nested = // create a nested view which is
                         // also instance of CleanupView
            this.$el.append(nested.$el);
    
            this.setNestedView(view);
        },
        cleanup: function() {
            // Cleanup current view only
        }
    });
    

Copyright (c) 2013 naorye

backbonecleanup's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.