ractivejs / ractive-adaptors-backbone Goto Github PK
View Code? Open in Web Editor NEWBackbone.js adaptor for Ractive
Backbone.js adaptor for Ractive
When having in a template like the following example using unescaped html triple mustache, it is not possible to get the the model updates after a user has change the input value.
<input type="text" value="{{{model.name}}}">
ractive.get('model.name')
It used to be that the event.context
of a Ractive proxy event contained the backbone model. Now it just contains a plain object with the model properties. However, if I call this.get(event.keypath)
then I do get a backbone model.
It seems to me that event.context
should contain the backbone model and not just the properties.
It seems like there's only one assertion in the test suite:
https://github.com/ractivejs/ractive-adaptors-backbone/blob/master/test/tests.js
It'd be difficult to just merge PRs right now unless more tests are added.
Hi. This adaptor is pretty great and very helpful for our projects.
I am running into an issue where calling a .sort()
on a collection does not prompt Ractive to re-render the HTML. The collection is indeed resorted, but this is not reflected in the DOM. Even with a manual ractive.update()
call, no changes.
I will work on making a JSFiddle to make this reproducable, but i just wanted to start the thread to see if there was something obvious I was missing.
Ideally, I should be able to put require('ractive-backbone')
in my app, but with a main property or an index.js
, I need to instead use `require('ractive-backbone/Racktive-Backbone').
Would be great to do after 0.2.0 once we've merged outstanding PRs.
Hi,
is there a reason to propagate a model change only for immediate child property ?
https://github.com/RactiveJS/Ractive-adaptors-Backbone/blob/master/src/Ractive-Backbone.js#L116
Thanks
Ractive has a ractive.merge()
operation which minimises the amount of DOM manipulation involved in updating list sections. It should be possible to use the same logic with Backbone collections.
I'm seeing a blank page on: http://examples.ractivejs.org/backbone
Is it just me or is the demo broken?
jsfiddle example: http://jsfiddle.net/zw4Pc/2/
in the example i bind to each model's .on('change') as i add them but they never get called when editing in the inputs. my naive understanding thinks we should bind to ractive .set and .update in the backbone adaptor. what do you think?
as a side-note, how does one do two-way binding in a list? in the example if you make multiple items they all have the same values.
cheers!
ractive
and backbone
need to be under peerDependencies
.
It might not work in browserify otherwise. x instanceof Backbone.Model
may check x
against a new instance of Backbone
from the one the user's probably already using.
Hello, I have found a bug that seems to only surface in very rare instances. Under the reset method for models, this.value.reset( object );
is used. Since this.value
is a Backbone model, calling reset()
will most certainly fail. I fixed this by replacing the whole function with return false;
. This might not be desirable, so instead perhaps this.value.clear().set(object);
would be better?
it work in 0.4.0: http://jsbin.com/tovik/5/edit?html,js,console,output
but fail in 0.6.0: http://jsbin.com/tovik/4/edit?html,js,console,output
there is a way to make it work in this version: http://jsbin.com/tovik/6/edit?html,js,console,output
Grunt for a 180-line library may be overkill. Since moving from qunit to mocha, the only functions grunt fulfills today is (1) jshint, and (2) uglifyjs compression.
My suggestions:
scripts: { test: "jshint ractive-adaptors-backbone.js && mocha" }
or mocha-jshint.npm run prepublish
to minify the js file. The prepublish hook is the npm standard for invoking build steps. This is done by adding { scripts: { prepublish: "uglifyjs -m < index.js > index.out.js" } }
to package.json.When a wrapped backbone collection contains a second backbone collection, the reset
call of the ractive-adaptor blows the call stack :(
Looks like the collection is wrapped twice. One time through misses the this.setting
check and gets .reset
. Which seems like it would be fine, except the this.value.reset( models )
triggers a 'reset'
event, which triggers the collection wrapper to reset again (and again, and again).
Adding {silent: true}
seems to fix this. That might be covering a symptom though.
Consider:
ractive.set( 'x', new Backbone.Model() );
ractive.set( 'x', new Backbone.Collection() );
This will treat the collection as a POJO and attempt to extend the model with it. That is:
// this doesn't make sense
model.set({ length: 0, models: [], _byId: {} });
There are some pros and cons to merge
ing as opposed to set
ing as is currently done here. A con would be performance is better with a set
, and a pro would be that elements would transition properly with merge
.
Prior to 0.8, it was impossible to merge an array with itself, so it may not be wise to do so until 0.7 and earlier are mostly out of use. See ractivejs/ractive#2203
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.