DataZombies / jQTouch

jQT extensions jqt.activityIndicator, jqt.bars (with numeric badges), jqt.checkGroup & jqt.segmentedControl.Get updates via Twitter http://twitter.com/HeadDZombie. If you find this fork useful please make a donation via PayPal (http://tinyurl.com/2fpmx27). See below for demo links.
MIT License
159 stars 34 forks source link

Image in backbutton overwritten with text #39

Closed barts2108 closed 13 years ago

barts2108 commented 13 years ago

Hi

I have just downloaded the latest sources, and I noticed something changed in jqt.autotitles.js

My back buttons all have an image instead of text

<div class="toolbar"> 
    <a href="#" class="back"><img src="images/backimg.png" alt="Back" /></a>
    <h1></h1>   
</div>                

When my div exists in the index.html, and it contains the above toolbar, and I load the content dynamically, the entire image tag for the back button is removed and replaced by text.

Whenever the entire div including the tooldbar is loaded dynamically, this does not happen.

In my opinion, whenever the anchor tack with class back has ANY content, autotitles must honor that content and not do anything. ANY content can be text or tags

Thus in the above, autotitles should only insert text in the h1 tag

DataZombies commented 13 years ago

You're absolutely right. I'll get that fixed this weekend.

DataZombies commented 13 years ago

Try the latest push. I altered the autoTitles demo to include an image in a backbutton.

barts2108 commented 13 years ago

Not works for me

Line 40 says $backButton.data('hardCoded') is undefined, causing not to set the data

if ($backButton.data('hardCoded') === null || 
   $backButton.data('hardCoded') === undefined) {

If I change to the above, it works for me. Probably line 48 must have the same modification

DataZombies commented 13 years ago

That's interesting. I'm not getting that error when I test in Safari. What browser are you using?

barts2108 commented 13 years ago

I am using on my desktop:

Safari 5.0.2 (7533.18.5) Chrome (10.0.648.133)

and devices: iPod touch 3.1.3 (7E18) iPod touch 4.2.1 (8C148) iPad 4.2.1 (8C148)

They all show text instead of image when I do not have a check for 'undefined'. Also if I debug this in the web inspector I see that $backButton.data('hardCoded') is undefined I never see Line 41 and 49 executed unless I add the check for undefined.

If I load the entire target page dynamically (including the header) then the image is on the back button (lines 41 and 49 still not executed). If I load the page partial (the header is in the main index already) then I have this problem.

I don't understand how the .data('hardCoded') can be null if it has never been created.

When I recall another issue in jqt.bars, a better check would be

if ($backButton.data('hardCoded') === null || 
   typeof ($backButton.data('hardCoded')) === 'undefined') {
barts2108 commented 13 years ago

Line 48 gave me the same problem for the title text. Updating with the same kind of check as above, solves the problem for the text too.

barts2108 commented 13 years ago

Seems that the title not hardcoded still has a problem when the new page (the entire div including the toolbar) is dynamically inserted using a real link in the anchor tag

Reason for this: shopagebyhref makes an ajax call. autotitles is handled between the ajax call and its reply.

Is it possible to get autotitles to be handled AFTER the ajaxcall showpagebyhref is finished ?

barts2108 commented 13 years ago

Bump ?

Anyone knows how to delay autotitles to do its job only AFTER showpagebyhref ajax call has completed, and not in between the ajax call and the completed event ?

DataZombies commented 13 years ago

I've just pushed a new version of autoTitles that will set the loaded page's backbutton. It's not possible to set the loaded page's title because $(e.target).data('referrer'), which contains the ID of the link the user clicked on, doesn't exist.

Here's the order of events for AJAX loaded pages: showPageByHref success pageInserted event pageInserted event pageInserted event pageInserted event pageAnimationStart event, direction: out pageAnimationStart event, direction: in pageAnimationEnd event, direction: in pageAnimationEnd event, direction: out

Delaying autoTitles, even if you could, wouldn't help.