opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Custom routing #147

Closed deanmcpherson closed 11 years ago

deanmcpherson commented 11 years ago

Hi,

I'm trying to use custom routing so that I can pass parameters to an angular controller on one of my pages. My route looks like

$routeProvider.when('/form/:id',{
    templateUrl:'test.html'
});

When I then click a link to form/some_id from the home page it works as expected and loads the template with the id parameter passed correctly to the controller. However If I navigate from the page form/some_id to for example to form/some_other_id then it starts loading, but dies with the js error

"Uncaught TypeError: Cannot call method '_trigger' of undefined" from line 4063 of jqm (uncompressed).

Am I doing something wrong or is this a bug?

tbosch commented 11 years ago

Hi, no, this should work as you explained. Could you provide a jsfiddle to make sure I understand you correctly?

The link for a starting jsfiddle is in the Readme.md.

Will look into this soon...

Thanks, Tobias

deanmcpherson commented 11 years ago

Hi Tobias,

I threw an example into the jsfiddle http://jsfiddle.net/VKTV3/1/

But I wasn't sure how to separate the separate pages (index.html and form.html) in jsfiddle.

Thanks,

Dean

tbosch commented 11 years ago

Hi, you can use a plunk with external pages, starting of from this one: http://plnkr.co/edit/ZrKB8H4fjnlak6WgKOTj I also added this template plunk in the Readme.md.

Tobias

tbosch commented 11 years ago

This plunk should contain your code, and it also does reproduce your problem: http://plnkr.co/edit/4BXrOYbicbXyqC4IAHO8

tbosch commented 11 years ago

Hi, ok, that's really a bug. It always occurs if you navigate from a template to the same template, and when the template is an external page and the dom cache of jquery evicts the page.

A workaround is to add data-dom-cache="true" to your page-div.

Here is an updated plunk:http://plnkr.co/edit/ioUvSfkMWEQuvtE9ZceG

Tobias

deanmcpherson commented 11 years ago

Thanks, the datat-dom-cache workaround worked for me.

Dean