I am new to iPhone web app writing but a fairly experienced programmer
- not an expert, but not complete newb either. Any way I stumbled
across iUI the other day and have been playing with it. I think it is
a really cool project/toolset. I am having trouble trying to customize
it though. For my first iUI app I wanted to make an iphone version of
some web apps we use at work just to play with systems i am familiar
with as i learn this tool. I hav got the basics of using iUI down but
for part of my project i need to hack the back button. I have a menu
list with options to enter info into a database it runs like this
simple diagram....

main menu > sub menu > form to enter data > after entering data get
dumped back on sub menu.

typically you would go through sub menu > data entry ----- loop a few
times before going back to the main menu so i don't want to rely on
history for the back button on the sub menu causing you to go back
through all the steps. Ideally I want the back button on the sub menu
page to always go straight back to the main menu.

I have been going over the code and have managed to change the name of
the back button only on the sub menu page by making this attribute.
<ul title="Sub Menu"  hackbackButton="true" hackbackButton_Name="Menu"
>
and adding this to the js file in the updatePage(page, fromPage)
function.

    var backButton = $("backButton");

        if (page.getAttribute("hackbackButton")){
                backButton.style.display = "inline";
                backButton.innerHTML = 'Sub Menu';
                //backButton.href = "sub_menu.php"; // Tried setting the link 
URL no
luck, moved on to the link event handler to try there.
        } else if (backButton) {
        var prevPage = $(pageHistory[pageHistory.length-2]);
        if (prevPage && !page.getAttribute("hideBackButton"))
        {
            backButton.style.display = "inline";
            backButton.innerHTML = prevPage.title ? prevPage.title :
"Back";
        } else {
            backButton.style.display = "none";
                }
    }

So then I started tracing through the code to find where the
navigation is done and made these additions to the addEventListener
("click", function(event) function....

        if (link.href && link.hash && link.hash != "#" && !
link.target)
        {
            link.setAttribute("selected", "true");
            iui.showPage($(link.hash.substr(1)));
            setTimeout(unselect, 500);
        }
                else if (link == $("backButton") && page.getAttribute
("hackbackButton") ){ // looking for hacked back button in pages then
I have been trying to call the showPageByHref() function
                        //history.go(URL)// couldn't get this to work at all
                        the_target = page.getElementById('data_form');
                        iui.showPageByHref('sub_menu.php', null, null, 
the_target,
unselect);
                }
        else if (link == $("backButton")){
                                history.back();
                }
so far everything just breaks the functionality of the back button. I
have no trouble saying i have puzzled over this a little over three
hours now. I'm in a little over my head and would appreciate any help
offered.

PS: I am sure that there are very few comments in the js file for good
reasons most likely keeping download small on iPhone, but could some
one who knows this stuff please post a commented one for those of us
trying to learn. This is a big step up from rollovers, and form
manipulation/validation. Thanks!!!!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to