This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Chad Lonberger
Posted Feb 03 - Read on Facebook

Question regarding loading JSON models from the local file system.. Didn't have any luck loading local JSON with Utils.domLoad* (via XMLHttpRequest) expectedly due to the same-origin policy.

Tried wrapping the model in js (see below) and including it in the index.html. It works but is proving to be error prone for PMs who are attempting to update the data (and the prototype) to fit their use-cases.

Aside from pushing the model to a server, Is there a preferred way to do this? Thanks in advance everyone.

data.js:
-----------
(function() {
this.data = {
"key": "val"
};

}).call(this);

2 Comments

Mike Feldstein

Here's another approach, since coffeescript supports multiline strings, you can format the data however you want. Here's a sample where I use colon separated values on each line to represent the data. You can make it as flexible as you want for PMs to manipulate it (like you might .trim() each string so that whitespace doesn't break anything), but unlike the super strict JSON format, you can make this more lenient.

http://share.framerjs.com/wedukcplbobq/

Chad Lonberger

Hey thanks for the suggestion Mike Feldstein

Read the entire post on Facebook