Comments (5)
Give you give me some example code, I can't replicate it?
from spine.
This is either an issue or by design? (Firefox)
var e1 = this.records[id];
var e2 = this.records[id].clone();
If I modify e1, the change is reflected in e2. If I modify e2, the change is not reflected in e1. In other words, modifying the original "updates" the clones. But modifying the clone does not appear to update the original.
from spine.
You shouldn't be accessing this.records[] directly - it's the raw records. Every function that returns records, such as find(), makes sure only proxies are returned. Yes, this behavior is expected.
The one place this catches people out, is in the following scenario:
var asset = Asset.create({name: "test", id: "foo"});
Asset.find("foo").updateAttributes({name: "test2"});
assertEqual(asset.name, "test2"); // fails
This is because asset
isn't a clone - so doesn't reflect updates. Unfortunately there isn't a cross browser way of setting the asset's prototype upon creation, turning it into a clone. There isn't a way around this apart from calling asset.reload()
. Hope that answers your question.
from spine.
So maybe this is a bug with Safari, not too sure. Took me a while to pinpoint what might be happening.
What's happening is that Object.create
doesn't work in the web inspector (at least in Safari 5.0.5 on Mac 10.6). Object.create
works for simple objects, such as Object.create({})
, but not on the Spine.js models.
But when the javascript runs in the browser (i.e. App.Models.Post.first()
is run when the script file loads, instead of me manually typing App.Models.Post.first()
into the web inspector), it works fine. So the code works, I just can't mess with it in the web inspector.
Changing the .clone
method in Spine.js from return Object.create(this);
to return this.dup();
solves this specific issue, but it probably will cause other problems. Writing javascript tests is cutting out the need to use the web inspector, so that's a better approach.
Thanks,
Lance
from spine.
Yes, complex objects not appearing in the console is a webkit issue, fixed
in the nightlies I believe. In the mean time you can solve it by doing
JSON.stringify(ob).
On Mon, Jul 18, 2011 at 4:16 PM, viatropos <
[email protected]>wrote:
So maybe this is a bug with Safari, not too sure. Took me a while to
pinpoint what might be happening.What's happening is that
Object.create
doesn't work in the web inspector
(at least in Safari 5.0.5 on Mac 10.6).Object.create
works for simple
objects, such asObject.create({})
, but not on the Spine.js models.But when the javascript runs in the browser (i.e.
App.Models.Post.first()
is run when the script file loads, instead of me manually typing
App.Models.Post.first()
into the web inspector), it works fine. So the
code works, I just can't mess with it in the web inspector.Changing the
.clone
method in Spine.js fromreturn Object.create(this);
toreturn this.dup();
solves this specific issue, but it probably will
cause other problems. Writing javascript tests is cutting out the need to
use the web inspector, so that's a better approach.Thanks,
LanceReply to this email directly or view it on GitHub:
https://github.com/maccman/spine/issues/61#issuecomment-1602986
Alex MacCaw
+12147175129
@maccman
http://alexmaccaw.co.uk | http://www.leadthinking.com | http://socialmod.com
from spine.
Related Issues (20)
- code help( help with the completion of the code to run well) HOT 3
- testing new issue HOT 5
- Why there are two different spinejs? HOT 4
- Do not mix up instance property and local variable HOT 5
- Broken link to coffeescript in README
- Crashes if the browser doesn't support localStorage HOT 1
- Triggering refresh on model instance no longer triggers refresh on the model class HOT 9
- `isBlank` suppose to check the number? HOT 4
- Support multiple remote hosts (override Spine.Model.host) HOT 1
- 1.6 ajax create success and then auto ajax update HOT 9
- hasOne and hasMany calls inconsistent
- listeningTo the same event on different models is broken (events.split / cannot read property 'obj' of undefined / etc.) HOT 3
- Extend POST/DELETE fix from 1.6.0 to PUT calls HOT 1
- spinejs.com domain registration has expired HOT 3
- Model#changeID does not persist the new id HOT 1
- Documentation link in README.md is broken HOT 2
- Model foreign key reference with no id broken HOT 2
- Model.find unable to get correct result
- Hello. Is this project abandoned? HOT 2
- Pug support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spine.