GithubHelp home page GithubHelp logo

backbonejs-bridge's Introduction

Strongly-Typed Javascript (STJS) Bridge to Backbone.js

The STJS bridge to Backbone.js gives you access to this great library using a Java syntax. All the functionalities of Backbone.js are available, but the code has to be written in a slightly different manner compared to the code you would've written directly in JavaScript.

This difference comes mainly from the way inheritance is implemented in Backbone.js (via _.extend of Underscore.js) compared to ST-JS. In Backbone.js the Views and Models properties are set BEFORE calling the constructor of the object - that afterwards calls the initialize method.

To obtain a similar behavior with ST-JS, when implementing Views you need to:

  • override the method _ensureElement and set there the "el" or "tagName" field and then call super._ensureElement
  • override the method delegateEvents and set the events map there and then call super.delegateEvents

For Models you always need to override the constructor public Model(Map<String, ? extends Object> attributes, ModelOptions options)

Please leave the constructors of Views and Models empty - use the initialize method instead.

One more matter where you need to be careful is the usage of "$" in Views. $ is a method of the View, so this.$ and $ is the same thing! So if you wish to access the global jQuery method, please call GlobalJQuery.$ (or other global object - @GlboalScope - that has this property set).

We're sorry for these limitations, we're working to find a transparent way for you the users. Your suggestions are welcome!

backbonejs-bridge's People

Contributors

acraciun avatar

Watchers

Stéphane Goetz avatar James Cloos avatar  avatar  avatar Nicolas Piguet avatar  avatar AzizBelhassan avatar

Forkers

sonthanh

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.