Page 1 of 1

Tap event auto re-navigateTo on back button click

Posted: Sun Jan 26, 2014 1:00 pm
by Tom6106181

Hi.
I have a ui-list of items, where I have a live tap event on each li a.

Working perfectly clicking to view the item, it navigate to correct viewItemScreen.

But when I click "back button" or any other navigation button (example HOME button) in the viewItemScreen, it goes to the correct "itemList/start-screen, but then automatically re-navigate to the itemViewScreen again (me not doing anything, it just re-fire the event for some reason).

Not sure how to stop this from happening. Any suggestion? die() or something after "tap"!?!

ui-list itemsScreen:
code$(".ui-listview").find('a.event-item-link').live("tap",function(){
if($(this).attr("rel")){
localStorage.setItem('eventId', $(this).attr("rel"));
Appery.navigateTo('itemViewScreen',{ transition: 'slide'});
} else {
return false;
}
return false;
});/code

viewItemScreen
codeRegular back button in header/code


Tap event auto re-navigateTo on back button click

Posted: Sun Jan 26, 2014 1:25 pm
by Tom6106181

Never mind.. It looks like I have sorted it out now;
code$(".ui-listview").find('a.event-item-link').die().live({
click: function() {
if ($(this).attr("rel")) {
localStorage.setItem('eventId', $(this).attr("rel"));
Appery.navigateTo('itemViewScreen', {
transition: 'slide',
reverse: false
});
}
},
});/code


Tap event auto re-navigateTo on back button click

Posted: Sun Jan 26, 2014 1:31 pm
by Alena Prykhodko

Glad you handled it :)


Tap event auto re-navigateTo on back button click

Posted: Tue Feb 18, 2014 11:41 am
by Tom6106181

Hi. After jquery mobile 1.4.0, I noticed that my live click is not working any more. I noticed you re-wrote the button click code for appery components as well (in js files). So now I am wondering, instead of the above, is this the best practice? or should I do it another way?

code

$(".ui-listview").find('.event-item-link').on({
click: function() {
if ($(this).attr("rel")) {
localStorage.setItem('eventId', $(this).attr("rel"));
Appery.navigateTo('itemViewScreen', {
transition: 'slide',
reverse: false
});
}
}
});

/code


Tap event auto re-navigateTo on back button click

Posted: Wed Feb 19, 2014 8:28 am
by Kateryna Grynko

Hi Tom,

Does this code work? Please don't change the library version if you started work with the old one, this will be easier.


Tap event auto re-navigateTo on back button click

Posted: Wed Feb 19, 2014 8:52 am
by Tom6106181

I started a new app from scratch, with latest libs, to see if there are something with me code, and to re-write the whole app more streamlined. So have 2 versions of it now (almost). Yes, the code work, but I am wondering if this is the best approach?

Basicly, I am building a ui-listview, and doing find all A.elements with class="event-item-link", and listen on click to navigate to the "viewpage" for the clicked item.


Tap event auto re-navigateTo on back button click

Posted: Wed Feb 19, 2014 10:51 am
by Kateryna Grynko

Tom,

If I understand you correctly, backbutton fires on listview click. If this is so, please post a public link, we'll test it.
Where do you reproduce this behaviour (desktop browser, native app, OS version)?


Tap event auto re-navigateTo on back button click

Posted: Wed Feb 19, 2014 11:40 am
by Tom6106181

Sorry, perhaps I was not clear enough :) I fixed the initial problem, as stated in next thread, but after I started a new app (to find the bloody xcode problem), I had to change the die.live to .on.

And question is simply, is this the best approach?


Tap event auto re-navigateTo on back button click

Posted: Wed Feb 19, 2014 11:46 am
by Kateryna Grynko

Tom,

Seems to be okay, use it if it works for you.