coderifous / jquery-localize

a jQuery plugin that makes it easy to internationalize your web site.
465 stars 142 forks source link

Jquery mobile a href and buttons issues #15

Closed i-vision closed 12 years ago

i-vision commented 12 years ago

Hello, thanks for great plugin.

Plugin have some issues if is using with JQM.

For example:

Nastavení

Reset

This: Reset

should to display button, but with using with rel attr is button deformed.

I tried use other attr's than rel, fxp: i18n but still same result.

I think, that problem should be via Ajax loading of pages in JQM.

I will glad if any fix.

Greeting

Jiri

johnallers commented 12 years ago

I have run into a similar issue. I'm currently working around this by calling localize before I load the jQuery Mobile JS file.

johnallers commented 12 years ago

I am currently working on some sort of workaround for this at https://github.com/johnallers/jquery-localize/tree/jqm-support

I have added a new option childSelector which applies localization to a child element, if a match is found. If no match is found, localization is applied to the element as it normally would.

For use with jQuery Mobile 1.0.1, apply localization to the .ui-btn-text element as such:

$.localize("[rel*=localize]", { language: "fr", childSelector: ".ui-btn-text" });
Antonio-Laguna commented 12 years ago

I havent tried but I think you should run the localize function within a pagecreate callback function.

Antonio-Laguna commented 12 years ago

I've made a little test and it's working flawlessly. Just do it in this way:

Using jQuery Mobile 1.1 and further

$(document).on('pagecreate','#home',function(event){
      $("[rel*=localize]").localize("index")
});

Pre jQM 1.1

$('#home').live('pagecreate',function(event){
      $("[rel*=localize]").localize("index")
});

Where #home is the ID of the page.

https://skitch.com/shadow450/8xjya/captura-de-pantalla-2012-04-03-a-la-s-13.50.46

johnallers commented 12 years ago

That makes a lot more sense than what I was trying to do.

Thanks Belelros!

coderifous commented 12 years ago

@Belelros Thanks for answering this!