I am trying to do this in the Index.html but not working

Forum for discussing building user interfaces for controlling MLServer using the iPhone or iPod Touch.
Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

I am trying to do this in the Index.html but not working

Postby Blade » Tue Mar 23, 2010 7:55 pm

I am trying to do this in the Index.html file but it does not seem to run the command map.

<li><a onclick="doMLCommand('Maslen.Music.Sirius');" href="Index.html#_sirius">Change Source To Sirius Radio</a></li>

It goes back to the right page but the doMLCommand does not appear to be running the command map.

Any ideas?

User avatar
jjjukebox
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1024
Joined: Sat May 22, 2004 9:54 pm
Location: Toronto
Contact:

Re: I am trying to do this in the Index.html but not working

Postby jjjukebox » Tue Mar 23, 2010 11:02 pm

Try:

<li><a onclick="doCommand('Maslen.Music.Sirius')" href="Index.html#_sirius">Change Source To Sirius Radio</a></li>

it is "doCommand " not "doMLCommand" and no ";" in there
J.J. Jukebox
Member

Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

Re: I am trying to do this in the Index.html but not working

Postby Blade » Wed Mar 24, 2010 7:27 am

Are you sure it is doCommand on the Index.html page. I do not see doCommand in the ui.js file which is what is being included in the Index.html file.
I do see doCommand in the iphone.js file but the Index.html does not use that file. I use doCommand a lot in all my other pages.

I just tried it and it did not work.
Here is what I tried:

<li><a onclick="doCommand('Maslen.Music.Sirius')" href="Index.html#_sirius">Change Source To Sirius Radio</a></li>

User avatar
jjjukebox
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1024
Joined: Sat May 22, 2004 9:54 pm
Location: Toronto
Contact:

Re: I am trying to do this in the Index.html but not working

Postby jjjukebox » Wed Mar 24, 2010 7:47 am

my apologies

I dont use the ui.js at all only a customized iphone.js
J.J. Jukebox

Member

Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

Re: I am trying to do this in the Index.html but not working

Postby Blade » Wed Mar 24, 2010 7:53 am

Even the doMLCommand, which looks the same as the doCommand, does not seem to run a command map on the index.html page.

The mlcmd tag does not seem to run a command map either.
Not sure how to do it now.

Blade
Expert
Expert
Posts: 760
Joined: Tue Nov 09, 2004 9:38 pm
Location: Lucan, Ontario
Contact:

Re: I am trying to do this in the Index.html but not working

Postby Blade » Wed Mar 24, 2010 8:34 am

Well I found out what the issue was...
This line runs fine:

<li><a mlcmd="Maslen.Music.Sirius" href="Index.html">Change Source To Sirius Radio</a></li>

But this one does not:

<li><a mlcmd="Maslen.Music.Sirius" href="Index.html#_sirius">Change Source To Sirius Radio</a></li>

The only difference is the #_sirius after the Index.html
No idea why this causes an issue.

wnl
Member
Member
Posts: 65
Joined: Mon Oct 26, 2009 10:19 pm
Contact:

Re: I am trying to do this in the Index.html but not working

Postby wnl » Wed Mar 24, 2010 7:32 pm

The onclick event handler handles the mlcmd property. There is a long if else chain in the handler, and the very first condition is:

Code: Select all

if (link.href && link.hash && link.hash != "#")


This first block gets run whenever the enclosing <a> contains an href with an anchor (link.hash != '#'), and the code that checks for mlcmd and calls doMLCommand never gets touched. Result: any <a> with an anchor in the href will have its mlcmd ignored. Very frustrating, but I haven't braved reworking this part of the code yet.

You can work around this problem by putting the <a> in a <span mlcmd="...">. I've done this in some parts of my index.html to get it to send a command and reposition elsewhere on the page. Example:

Code: Select all

<span mlcmd="Theater.PowerOff"><a class="whiteButton" href="#home">All Off</a></span>


As for why a direct call to doMLCommand didn't work fro onclick, I'm not certain but I suspect it is because doMLCommand calls the open method of XMLHttpRequest in such away that the send does not wait for a response (second argument is false). Perhaps the immediate page load is deleting the XMLHttpRequest object before it gets a chance to send the request? Refer to this line:

Code: Select all

xmlcmdui.open("GET", "/MLCMD?" + escape(aCmd), false);

wnl
Member
Member
Posts: 65
Joined: Mon Oct 26, 2009 10:19 pm
Contact:

Re: I am trying to do this in the Index.html but not working

Postby wnl » Wed Mar 24, 2010 7:38 pm

Blade wrote:<li><a mlcmd="Maslen.Music.Sirius" href="Index.html#_sirius">Change Source To Sirius Radio</a></li>


Try this:

<li><span mlcmd="Maslen.Music.Sirius"><a href="#_sirius">Change Source To Sirius Radio</a></span></li>

The span might mess up other formatting, but it should run the mlcmd. FYI: the href doesn't need to include "index.html" if it is on that page already. You only need the anchor (#_sirius).


Return to “iPhone / iPod Touch Beta”

Who is online

Users browsing this forum: No registered users and 1 guest