logo
down
shadow

Backbone history and require.js issue


Backbone history and require.js issue

Content Index :

Backbone history and require.js issue
Tag : javascript , By : user143038
Date : December 01 2020, 04:55 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Backbone.js (with Require.js) variable/scope access issue


Tag : javascript , By : user104292
Date : March 29 2020, 07:55 AM
it should still fix some issue I've decided my best option is to use the global namespace as suggested by Addy Osmani, BUT I think if I needed an alternative option then I would just set an instance specific property like so:
contacts_view.contact = new ContactView({
    el: $('#view-contact')
});
var ContactsView = Backbone.View.extend({
    events: {
        'change select': 'display_selected'
    },

    display_selected: function (event) {
        this.contact.render(model);
    }
});
var contacts_view = new ContactsView({
    el: $('#view-contacts'),
    collection: contacts,
    associated_view: new ContactView({
        el: $('#view-contact'),
        collection: contacts
    })
});

Backbone.history.start() issue


Tag : backbone.js , By : nagre
Date : March 29 2020, 07:55 AM
it fixes the issue [SOLVED] the JS files (JQuery, Underscore and Backbone were added to HTML in the wrong order. The right order for me was: JQuery, Underscore, Backbone, MyOwnJSFiles. anyone for reading, hope this helps

Getting issue while installing Backbone-Require-Boilerplate


Tag : npm , By : jaime
Date : March 29 2020, 07:55 AM
hope this fix your issue I didn't installed the git yet while trying these things. That's why i have got this error. My issue gets resolved after installed the git.
They didn't mentioned anything about git on https://github.com/BoilerplateMVC/Backbone-Require-Boilerplate. Download the git from: http://git-scm.com/ and try install the npm package after git installation.

Render issue in View with subviews in Backbone/Require app


Tag : javascript , By : Adil
Date : March 29 2020, 07:55 AM
To fix the issue you can do I think you just need to remove el: $('#gradescontainer') from GradesView. You shouldn't set the el element for a subview since you are going to append it to the parent view that is not rendered yet.
I included a ver simplified version that works just by el: $('#gradescontainer'). In my example I removed the GradeModel and GradeCollection and just put some placeholder code for simplicity.
this.collection.on('add', this.renderGrade, this);
var GradeView = Backbone.View.extend({
  tagName: 'div',
  initialize: function(){
    this.render();
  },
  template: "GRADE TEMPLATE",

  render: function() {
    this.$el.html(this.template);
    return this;
  },
});


var GradesView = Backbone.View.extend({
  initialize: function(){
    this.render();
  },
  render: function() {
    var self = this;
    for (var i = 0; i < 5; i++) {
        self.renderGrade({id:i});
    }
  },

  renderGrade: function(item) {
    this.gradeView = new GradeView({model: item});
    this.$el.append(this.gradeView.el);
  },
});

var HomeView = Backbone.View.extend({
   el: $('#test'),
   initialize: function() {
     this.gradesView = new GradesView();
     this.render();
   },
   template: '<h1>GRADES</h1><div id="gradesviewcontainer"></div>',
   render: function() {
     this.$el.html( this.template );
     this.$('#gradesviewcontainer').html( this.gradesView.el );
   },

 });

var v = new HomeView();
var GradeModel = Backbone.Model.extend({
  defaults: {
    letter: 'A'
  }
});

var GradesCollection = Backbone.Collection.extend ({
  model: GradeModel,
  url: '/grade'
});

var GradeView = Backbone.View.extend({
  tagName: 'div',
  initialize: function(){
    this.render();
  },
  template: _.template("<li><%= letter %></li>"), 
  render: function() {
    this.$el.html(this.template(this.model.attributes));
    return this;
  },
});


var GradesView = Backbone.View.extend({
  initialize: function(){
    this.collection = new GradesCollection();
    this.collection.add(new GradeModel({letter: 'A'}));
    this.collection.add(new GradeModel({letter: 'B'}));
    this.collection.add(new GradeModel({letter: 'C'}));    
    this.collection.add(new GradeModel({letter: 'D'}));
    this.render();
  },
  render: function() {
    this.collection.each( function (item) {
      this.renderGrade( item );
    }, this )
  },

  renderGrade: function(item) {
    this.gradeView = new GradeView({model: item});
    this.$el.append(this.gradeView.el);
  },
});

var HomeView = Backbone.View.extend({
  el: $('#test'),
  initialize: function() {
    this.gradesView = new GradesView();
    this.render();
  },
  template: '<h1>GRADES</h1><div id="gradesviewcontainer"></div>',
  render: function() {
    this.$el.html( this.template );
    this.$('#gradesviewcontainer').html(this.gradesView.el);
  },

});

var v = new HomeView();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<div id="test"></div>

require.js, backbone and cordova issue


Tag : cordova , By : ffmmjj
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • Does using try / catch rather than `.catch` observable operator with XHR requests reduce performance?
  • In IE11 background colors not working on printing
  • TypeScript interface signature "(): string"
  • Is synchronous XMLHttpRequest supported in Internet Explorer 10 and 11?
  • Axios function not returning any values with js
  • How to use firestore TIMESTAMP to create time-stamp in JavaScript
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com