Page 1 of 1

Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 1:57 pm
by Jon

Hi Tiggzi team,

Thanks for the help you've given me in trying to narrow down the best localStorage option for my Tiggzi apps. I now realize that SQLite is no longer a standard and that IndexedDB is not yet a standard. So adding a library to the localStorage API seems like the best plan for me for now. When chosing between lawnchair and store.js, I've gone with store.js for now.

I enjoyed the tutorial "getting started with html5 local storage." I'm now trying to implement this store.js library into the app I made for that tutorial, keeping the functionality but replacing the code.

My trouble is that we're not able to successfully implement this library in Tiggzi. When we do an outside of Tiggzi build the library works fine. But I am suspecting we're missing something about the Tiggzi syntax we should be doing. I tried playing with the codedsid/code attribute as you describe here. But I still must be missing something.

Can you help? You're free to poke around my app. It's called "tutorial - getting started with html5 local storage". You'll see the new buttons I added for the store.js library.

Here is the standard store.min.js library from github. All I did was move the comment to the bottom to make absolutely sure it would not conflict with the Tiggzi interpreter.


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 2:36 pm
by Kateryna Grynko

Hi Jon,

I can't see your project. Could you share it with support@tiggzi.com please?


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 3:28 pm
by Jon

Sorry, I didn't realize you didn't normally have access. I just shared it.


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 3:30 pm
by Kateryna Grynko

Thank you for sharing. We will take a look and I'll update.


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 3:51 pm
by Maryna Brodina

Hello! Could you clarify please what exactly happens when you are saying "not able to successfully implement this library"? Did you get any error?


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 4:50 pm
by Jon

Sure thing. For example, my 'save store js' button has this custom JS to execute when it is clicked: codestore.set('username',[dsid="input"]);/code

And my 'show store js' button shows has this custom JS for the click event: precodevar a=store.get('username');
alert(a);/code/pre

I was hoping that it would take what I put in that input field (and the object of the input object is named 'input') and put it in the alert.

Instead what I get in the alert is:
input

Does that make more sense? I think I must be incorrectly referring to the Tiggzi object?

The function call works ok if I don't try to connect it to the Tiggzi 'input' object, so that's why I think I must be missing something in my Tiggzi syntax. Here's the code i use when I don't try to connect it to the Tiggzi object:
for save button:
codestore.set('user', { name: 'marcus', likes: 'javascript' })/code

for show button:
precodevar user = store.get('user')
alert(user.name + ' likes ' + user.likes)/code/pre

When I replace the save button code with this it still doesn't work:
codestore.set('user', { name: 'marcus', likes: '[sdid='input']' });/code

Does that help you get an idea what my trouble is? I think I just need to understand better how to call a Tiggzi object within a library function?


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 5:58 pm
by Maryna Brodina

Thank you for description!

Use Tiggzi("input").val()

Here is how it should be

store.set('user', { name: 'marcus', likes: Tiggzi("input").val() });


Trouble implementing JS library (store.js)

Posted: Thu Jan 10, 2013 6:57 pm
by Jon

Thanks, Marina, that worked!