backbone.js

Facebook OG gets redirected to the index page by BackboneJS website

二次信任 提交于 2020-01-13 19:32:27
问题 I have a website that is created using BackboneJS and I am trying to implement Facebook OG so that when user pastes my site's URL from the Facebook status, it will display the title, images and etc. My problem is that the FB scraper is getting redirected always to the index page due that Apache redirects all traffic to the index page so BB router can work properly. It only sees the og title, og image and etc that was for the index page and not on my other page. Facebook scraper/crawler does

External templates and “el” with Knockout and RequireJS?

孤者浪人 提交于 2020-01-13 18:55:14
问题 I am trying to use Knockout ViewModels as self-contained "widgets" that can be placed into any (or multiple) DOM nodes on the page. I had an approach in Backbone that seemed to work well and I'm trying to convert the concept to Knockout. In Backbone view I would do something like this, using the RequireJS text plugin to pull the template and inject it into the el: define(['text!templates/myTemplate.html',], function(templateHTML){ var view = Backbone.View.extend({ initialize:function() { //

Can I force an update to a model's attribute to register as a change even if it isn't?

≯℡__Kan透↙ 提交于 2020-01-13 10:13:05
问题 I know that I can set the value of a Backbone model's attribute so that it doesn't trigger a change event using {silent:true} . I also know that if I set a model's attribute to a value it already has, it won't trigger a change event, which is almost always a good thing. However, is there a way to force the update to the model to trigger a change event even if it's set to the same value? So if within my model I have set: defaults:{ attributeToChange: "myValue" } And then in the a view using

Can I force an update to a model's attribute to register as a change even if it isn't?

拟墨画扇 提交于 2020-01-13 10:12:57
问题 I know that I can set the value of a Backbone model's attribute so that it doesn't trigger a change event using {silent:true} . I also know that if I set a model's attribute to a value it already has, it won't trigger a change event, which is almost always a good thing. However, is there a way to force the update to the model to trigger a change event even if it's set to the same value? So if within my model I have set: defaults:{ attributeToChange: "myValue" } And then in the a view using

Backbone events with wildcards

て烟熏妆下的殇ゞ 提交于 2020-01-13 09:12:11
问题 Is there a way to listen to all events of a namespace. So when I listen to an event like this: app.vent.on('notification(:id)', function(type){console.lof(type)}) It will listen to all events likes this: app.vent.trigger('notification:info') app.vent.trigger('notification:error') app.vent.trigger('notification:success') 回答1: No. Backbone typically fires a general eventName event, as well as eventName:specifier event. An example of this is Model.change , which allows you to listen to all

backbone.js - how to communicate between views?

大兔子大兔子 提交于 2020-01-12 17:30:07
问题 I have a single page web app with multiple backbone.js views. The views must sometimes communicate with each other. Two examples: When there are two ways views presenting a collection in different ways simultaneously and a click on an item in one view must be relayed to the other view. When a user transitions to the next stage of the process and the first view passes data to the second. To decouple the views as much as possible I currently use custom events to pass the data ( $(document)

Loading templates with backbone js

喜你入骨 提交于 2020-01-12 14:05:12
问题 I'm starting in javascript development, and did a simple project with node.js as a rest API and a client using backbone, everything look perfectly till I want to get my templates out of my js. I found different approaches, some of them with some time (like one year old) but I can't understand which one could be better: A .js file with a var with the html code pros -> easy to load, easy to pass to underscore to compile it. cons -> scape every single line. app.templates.view = " \ <h3>something

Loading templates with backbone js

流过昼夜 提交于 2020-01-12 14:01:33
问题 I'm starting in javascript development, and did a simple project with node.js as a rest API and a client using backbone, everything look perfectly till I want to get my templates out of my js. I found different approaches, some of them with some time (like one year old) but I can't understand which one could be better: A .js file with a var with the html code pros -> easy to load, easy to pass to underscore to compile it. cons -> scape every single line. app.templates.view = " \ <h3>something

Loading templates with backbone js

跟風遠走 提交于 2020-01-12 14:00:12
问题 I'm starting in javascript development, and did a simple project with node.js as a rest API and a client using backbone, everything look perfectly till I want to get my templates out of my js. I found different approaches, some of them with some time (like one year old) but I can't understand which one could be better: A .js file with a var with the html code pros -> easy to load, easy to pass to underscore to compile it. cons -> scape every single line. app.templates.view = " \ <h3>something

Remove an attribute from a Backbone.js model

点点圈 提交于 2020-01-12 11:07:33
问题 Is there a way to remove an attribute from a Backbone model? Reason being is I pass up extra data on save to perform certain actions, but then that data gets automatically added to my model The documentation says to not edit the model.attributes directly, so the only other method I see to do this would be to use the set method and set the attribute to null, but that is not ideal var myModel = new Model() myModel.save({name:'Holla', specialAttr:'Please Remove me'}) myModel.set({tempAttr:null})