backbone.js

Searching for text inside nested object (Backbone.js collection as example)

人盡茶涼 提交于 2020-01-22 15:42:26
问题 I have a backbone.js collection where I need to do a fulltextsearch on. The tools I have at hand are the following: Backbone.js, underscore.js, jQuery For those not familiar with backbone: A backbones collection is just an object. Inside the collection there is an array with models. Each model has an array with attributes. I have to search each attribute for a string. The code I am using for this is: query = 'some user input'; query = $.trim(query); query = query.replace(/ /gi, '|'); var

How do I track router change events in Backbone.js

流过昼夜 提交于 2020-01-22 09:24:46
问题 I need to run a function every time the application switches URLs in Backbone.js, and I need to know the hashtag the URL has changed to. I'm assuming there is an event that I can bind to but I haven't been able to figure out which event and what object to bind to. Specifically I want to ship the new URL to an analytics application. 回答1: I know this is an old post, but like @kirk suggested, Backbone.js already has it built it. Backbone.history.on("all", function (route, router) { //console.log

Should I use a central event bus with backbone.js?

邮差的信 提交于 2020-01-22 05:56:47
问题 I am currently working on my first backbone.js app. The concept of events is quite familiar to me but I am in question if I should use a central event dispatcher or not. Generally I see these two approaches: Directly wire event publishers and event receivers together. (I started with this approach.) Use an event bus and wire publishers and receivers to this bus. Is it favorable to use an event bus in terms of e. g. long time maintainability of the app and traceability of events? 回答1: Whether

Should I use a central event bus with backbone.js?

删除回忆录丶 提交于 2020-01-22 05:56:12
问题 I am currently working on my first backbone.js app. The concept of events is quite familiar to me but I am in question if I should use a central event dispatcher or not. Generally I see these two approaches: Directly wire event publishers and event receivers together. (I started with this approach.) Use an event bus and wire publishers and receivers to this bus. Is it favorable to use an event bus in terms of e. g. long time maintainability of the app and traceability of events? 回答1: Whether

How to detect model parameter change event in mithril.js?

ぃ、小莉子 提交于 2020-01-21 14:39:12
问题 I recently started learning mithril.js and I'm wondering how can I make very basic Model -> View one way data binding app. TestModel = function(data){ this.name = m.prop(data.name) } testModel = new TestModel({name: "John"}) code above declare a model and it works perfectly as getter/setter. but how can I set an event listener for the model event like Backbone's listenTo('model',"change",callbackFunc) ? all sample codes I saw are setting events for actual user actions like click , keyup or

clicking on child element also triggers click event on it parent [duplicate]

爱⌒轻易说出口 提交于 2020-01-21 12:49:31
问题 This question already has answers here : jquery stop child triggering parent event (8 answers) Closed 5 years ago . Scenario My view in my backbone app consists of several boxes(which are div elements) . When user clicks on one box and hold down the mouse button for 500 millisecond, then I want to show a delete button on top left corner. When user clicks on anywhere else #wrapper then that delete button should hide. Problem So showing delete button is not the issue. It does show delete button

Using Phantom.js evaluate, how can I get the HTML of the page?

两盒软妹~` 提交于 2020-01-21 09:00:52
问题 page.evaluate(function() { return document; }, function(result){ console.log(result) next(); }); result is actually a huge object. I don't know the properties and attributes of that object. I just want the HTML of the page as you would see it in Chrome inspector . From the look of the object, it seems that the HTML includes CSS and javascript..which is weird. The user should not see the CSS and javascript, because they are not the web page's HTML. Those are external files. I only want the

Backbone model save

*爱你&永不变心* 提交于 2020-01-21 03:45:10
问题 I'm using rails and learning Backbone. Help me please. Is there any way to set right model on save? When I create, for example, new user with some params and trying save it into the database, - on server side I have not user as object, but user fields in params. And only way to save user - is to set properties manually: user = User.new(:login => params[:login], :password => params[:password]).save! Is there any way which will generate real user model object (like a form_for generates)? I

Backbone.Js Collection with Specific Types

一笑奈何 提交于 2020-01-20 19:42:49
问题 I have a BackboneJS collection called History which can contain one of several Backbone JS models (which extend from HistoryItem which extends from Backbone.Model), I trying to find a way to have this recreated when loading, unfortunately it seems BackboneJS collection can only specify at particular model e.g. HistoryCollection = Backbone.Model.extend({ model: app.models.HistoryItem }) What I really need to do is determine this per type, here is what I'd like to do HistoryCollection =

API for backbone will be accessible by other website or devices

久未见 提交于 2020-01-17 07:12:46
问题 I am new in backbone, I am using php with Laravel framework as my server side language. I read to creating a single page application, I should create an API on my server side. Is this right (I should have an API for backbone single page application)? Is this secure? (Other websites or devices like Android software can access it?) 来源: https://stackoverflow.com/questions/28734575/api-for-backbone-will-be-accessible-by-other-website-or-devices