0

I've got a valid and working page that begins with this definition:

div data-role="page" data-theme="b" id="alkohol.test" data-url="alkohol.test" tabindex="0" class="ui-page ui-body-b ui-page-header-fixed iscroll-page ui-page-active" >

This is called properly and being displayed like it should but it seems not to fire on page init event. My code:

$( '#alkohol.test' ).live( 'pageinit',function(event){

console.log("Test successfully loaded!");
});  

When I change the page id to "alkoholtest" then it fires on pageinit. I assume that dots aren't allowed and I think that it's all about jquery selectors that expects id "alkohol" followed by the class "test" - but I want it to react to the page id being called. Is there a workaround for this problem? I mean without changing the dot to something else because I've got tons of code that will be a nightmare to change. Escaping or something?

Hexodus
  • 12,361
  • 6
  • 53
  • 72

1 Answers1

2

As mentioned here: How to select html nodes by ID with jquery when the id contains a dot? and here: jQuery dot in ID selector?

you have to escape the dot which makes jQuery treat 'test' as a class name

$('#alkohol\\.test')

or make sure that the whole string is understood as an ID

$("div[id='alkohol.test']")
Community
  • 1
  • 1
Paweł Chorążyk
  • 3,584
  • 3
  • 27
  • 33
  • Oh wow, this was a fast answered one. Thank you Paweł, this is exactly what I was searching for. I previously tried to escape it the php-regex-style with one a single backslash but i never came to try it with double backslashes. Thanx again and greetings to my old homeland Poland. – Hexodus May 22 '13 at 19:20