Jon
Posts: 0
Joined: Wed Dec 26, 2012 3:37 am

Trouble implementing JS library (store.js)

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Trouble implementing JS library (store.js)

Hi Jon,

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

Jon
Posts: 0
Joined: Wed Dec 26, 2012 3:37 am

Trouble implementing JS library (store.js)

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Trouble implementing JS library (store.js)

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Trouble implementing JS library (store.js)

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

Jon
Posts: 0
Joined: Wed Dec 26, 2012 3:37 am

Trouble implementing JS library (store.js)

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?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Trouble implementing JS library (store.js)

Thank you for description!

Use Tiggzi("input").val()

Here is how it should be

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

Jon
Posts: 0
Joined: Wed Dec 26, 2012 3:37 am

Trouble implementing JS library (store.js)

Thanks, Marina, that worked!

Return to “Issues”