how to manually set the data-url on a Jquery Mobile page which has an id attribute specified?

2.1k Views Asked by At

I'm a little lost...

I need my Jquery Mobile page to have an id, but set the data-url to file path. By default JQM takes the filepath as data-url, but if an id is supplied, the data-url will be overwritten with the id, which I don't want.

So:

<div id="some" data-role="page"></div>

Will result in:

<div id="some" data-role="page" data-url="some"></div>

While I need it to be:

<div id="some" data-role="page" data-url="/path/to/this/file.html"></div>

I'm trying to manually set the data-url, but it does not work like this:

$('div:jqmData(role="page")')
     .jqmData('url', $.mobile.path.parseUrl( window.location.href ).pathname )

Question:
What am I doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

Ok. Seems this only works like this:

$('div:jqmData(role="page")').attr({'data-url': $.mobile.path.parseUrl( window.location.href ).pathname});