Using a JS Array to populate a JSON for a directive.

1 view
Skip to first unread message

bigcl...@gmail.com

unread,
May 14, 2013, 2:57:56 AM5/14/13
to Pure-Unobtrusive...@googlegroups.com
I'm only a few weeks into Pure ... and still learning.

I understand how to use both a HTML template and callback JSON data from a JS file.

I'm not happy using the sample JsonData "data.js" file because of it's repetitive use of variable keyword names.

It one has a long list .. then it requires lots of extra work and space .. plus it must slow down the system.

I would like to use multiple arrays .. such as:

yaxis = new Array();
yaxis[0] = new Array('#1,'a','b','c','d');
yaxis[1] = new Array('#2,'e','f','g','h');
yaxis[2] = new Array('#3,'i','j.','k','l');

etc ...

then callback thru the JsonData to populate the data via yaxis[yyy][xxx] .. instead of using directive variables twice ( once in the HTML template .. and once in the JsonData JS file.

I could post my current attempt .. but it is nothing more than your "Hello Bebow!" sample merged with the 'people.name / person.team' template.

So I have a question or two .. :

1.) Must the jsonData function that propagates the directives be included in the HTML template? ( Can it be migrated to another separate JS file? ) .. I tried with no luck.

2.) There was two distinct demos using $p().render(json,directive) and $().directives.render(json) .. I can't determine the difference .. except the latter had the data within the script. Is one Pure and the other JQuery . JS ?

3.) Is there more tutorials / samples that are simple I can't find? I have coded in a forgotten language ( WebSiphon ) in my past with fantastic results. This week its Pure .. and I'm just beginning to understand why it is perfect for my concept .. took a long time to find it thru understanding terminology. Please bear with me while I ask some of these questions.  Thanks :)

Basically I am trying to build a infinitely expandable database via arrays instead of SQL ( since most servers require SQL administration )

Also .. I am trying to access data in only select areas of arrays .. instead of loading heaps of variables.

The JQuery interface seems to work great .. so that the page doesnt have to reload for every selection. Also .. given further commands .. memory extensive media .. such as audio and video . can be manipulated to 'Not' preload 100% .. and still be accessible upon returning without resetting the preloading. ( This is quite a feature )

I would be very happy to share anything I learn and all templates for a little help understanding.

Hope this description isnt too extensive.

Thanks to all .. it is a worthwhile project .. and I promise entertaining when finished! :)




Mic (BeeBole)

unread,
May 14, 2013, 6:18:09 AM5/14/13
to Pure-Unobtrusive...@googlegroups.com

1.) Must the jsonData function that propagates the directives be included in the HTML template? ( Can it be migrated to another separate JS file? ) .. I tried with no luck.

Yes. Directives are a Javascript object that could be on a separate location. 

 
2.) There was two distinct demos using $p().render(json,directive) and $().directives.render(json) .. I can't determine the difference .. except the latter had the data within the script. Is one Pure and the other JQuery . JS ?

It is a jQuery specific interface. Not sure it was a good idea after all.
 

3.) Is there more tutorials / samples that are simple I can't find? I have coded in a forgotten language ( WebSiphon ) in my past with fantastic results. This week its Pure .. and I'm just beginning to understand why it is perfect for my concept .. took a long time to find it thru understanding terminology. Please bear with me while I ask some of these questions.  Thanks :)

Basically I am trying to build a infinitely expandable database via arrays instead of SQL ( since most servers require SQL administration ) 

There are some demo/examples on the site.
Some tutorials you get when downloading the zip from http://github.com/pure/pure.
Search the word "gist" on this forum to get plenty of examples.

Our web app is a page divided in widgets. And I found that arrays are great to store a dynamic tree structure compared to JS hashes.
And since HTML is as well a tree structure the code to merge them can be very compact.

Good luck for your database! Feel free to post the link to your project's page, if/when you have one.

bigcl...@gmail.com

unread,
May 14, 2013, 10:26:40 AM5/14/13
to Pure-Unobtrusive...@googlegroups.com
Thanks a bunch MIc ... your responses and in-kind support to others made me look deeper into the Pure scripting.

I will be back here with my template .. :)

bigcl...@gmail.com

unread,
May 19, 2013, 3:00:29 PM5/19/13
to Pure-Unobtrusive...@googlegroups.com
Thanks for recommending searching for "gist" files in the group. I have not seen this 'tip' in the main BeeBole 'tree' .. and I recommend that it should be posted for others .. maybe it will save time on both ends.

I am having a hard time adding a "new array" to a jsonData '.js' file .. every iteration I write creates a error .. 

None of the gist file pertain to what I am looking for.

I'm still trying .. just don't understand why this can be so hard.

I have no idea how the above remark highlighted in yellow as well. I can't get rid of that either. :(
Reply all
Reply to author
Forward
0 new messages