JSFiddle

  • Backbone Template

    Standard fiddle

    SearchView = Backbone.View.extend({
      initialize: function() {
        this.render();
      },
      render: function() {
        var template = _.template($("#search_template").html());
        this.$el.html(template ...
  • Mustache Example 1

    Binding a primitive anonymous variable

    _.mixin({
        chunk: function(a, n) {
            // Based on lodash's
            var i = 0, length = a.length, ri = -1;
            var result ...
  • Coffeescript multiple for in loops

    No-Library (pure JS), HTML, CSS, CoffeeScript

    numbers = [1..20]
    
    addLetters = (number) ->
        [ "#{number}A", "#{number}B" ]
    
    for number in numbers  
        for pair in addLetters number 
            console.log ...
  • Backbone.js template

    jQuery 1.11.0, HTML, CSS, JavaScript

    var app = app || {};
    var Item = Backbone.Model.extend({
        defaults: {
            order: '',
            title: '',
            price: 0.01,
            inCart: false
        }
    });
    
    var item1 = new Item ...
  • Backbone - listenTo()

    Backbone - listenTo()

    var NModelo = new Backbone.Model({
        comments: 'comments',
        minutes: 'minutes'
    });
    var NView = Backbone.View.extend({
        tagName: 'span',
        render: function(){
            $(this.el ...
  • Backbone - listenTo()

    Backbone - listenTo()

    var EditView = Backbone.View.extend({
        events: {
            'click #button-yes': 'buttonClickHandler'
        },
        template: _.template('<section id="EditView"><button id="button-yes">YES</button></section>'),
        initialize: function () {
            this.render();
        },
        render: function () {
            this ...
  • Backbone - listenTo()

    Backbone - listenTo()

    var TheModel = Backbone.Model.extend({
        default: {
            photos: '',
            stat: ''   
        }
    });
    
    var TheCollection = Backbone.Collection.extend({
        model: TheModel,
        url: function() {
            return 'http://api ...
  • Backbone - listenTo()

    Backbone - listenTo()

    var pageNumber = 1;
    
    var TheModel = Backbone.Model.extend({
        default: {
            photos: '',
            stat: ''   
        }
    });
    
    var TheCollection = Backbone.Collection.extend({
        model: TheModel,
    
        //url: 'http ...
  • Backbone - listenTo()

    Backbone - listenTo()

    var pageNumber = 1;
    
    var TheModel = Backbone.Model.extend({
        default: {
            photos: '',
            stat: ''   
        }
    });
    
    var TheCollection = Backbone.Collection.extend({
        model: TheModel,
    
        //url: 'http ...
  • Backbone Sub Views - this.$el not woring

    Backbone Sub Views - this.$el not woring

    var TheModel = Backbone.Model.extend({
        defaults: {
            color: 'Red',
            message: null,
            endLine: null
        }
    });
    
    var TheCollection = Backbone.Model.extend({
        model: TheModel,
        
        url ...