Page 1 of 1

javascript code to open a popup?

Posted: Sun Oct 07, 2012 5:25 pm
by Agon Bina

I looked into the javascript api but couldn't understand it correctly.

If I want to open a popup using javascript, how do I do it?

let's say the popup name in the app builder is addPlayer.
I tried using Tiggr('addPlayer').open();
but it won't work.

thanks!


javascript code to open a popup?

Posted: Sun Oct 07, 2012 9:46 pm
by Agon Bina

I would also like to know how to invoke a service using javascript? :)
I.e. after a line has been executed on a custom javascript code, I would like to invoke a service.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 10:22 pm
by maxkatz

javascript code to open a popup?

Posted: Sun Oct 07, 2012 10:25 pm
by maxkatz

To open a popup, you need to use jQuery Mobile API.

code
$.mobile.changePage("pop.html", {transition: "pop"});
/code

where the popup name is 'pop'.

If you check the option to render all pages into one file (Project Project Profile General), then you can use this:

code
$.mobile.changePage($('div[dsid="pop"]'), {transition: "pop"});
/code

All the API you need is here: http://jquerymobile.com/demos/1.2.0/d...

You can also use Open as Popup action in the builder.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:08 pm
by Agon Bina

hmmm this works on the browser but it's not working on the tiggzi app tester. I was doing the navigateTo('addPlayer', 'ajax'); till you told me about this and same thing was happening. The popup loaded on the browser, ie when im testing it on the phone browser OR the pc browser. But when I load it up on the app tester, it doesn't work.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:08 pm
by Agon Bina

I am talking about the pop up by the way.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:18 pm
by maxkatz

Try with Open as Popup action, it works when I'm testing it.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:43 pm
by Agon Bina

Yeah that works , but I am checking if two variables are equal then opening the popup. If those two variables are not equal then there is no need for the popup. Do you know what I mean? I could probably think of another solution(ie just use another screen instead of the popup) but the popup would be a better solution.


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:46 pm
by maxkatz

Try this:

code
Tiggzi.navigateTo('pop', {transition: 'pop'});
/code


javascript code to open a popup?

Posted: Sun Oct 07, 2012 11:51 pm
by Agon Bina

It's working now ... the problem was something else though, all of the above commands should work too, it's just that there was a problem with the local variable which was being saved on the local storage on my phone ... that was causing a problem when i was checking whether to open the popup or not.

Thanks Max! You are awesome :)