1Marc / jquery-mobile-routerlite

A lightweight and simple router for jQuery Mobile.
27 stars 9 forks source link

routechange not firing on children with # routes #1

Open naugtur opened 11 years ago

naugtur commented 11 years ago

I had no idea how to create a title that would not be that cryptic ;)

$.mobile.routerlite.routechange("/", function(page, path){ console.log('!'); });

The code above logs to console on every page I visit except it doesn't log anything when I go to a page that is not loaded from a path, like: /#pageB

Is that desired? I would understand it's not a route change, but I can do:

$.mobile.routerlite.routechange("pageB", function(page, path){ console.log('hmm'); });

and it works.

1Marc commented 11 years ago

Would methods like .hashchange and .onhashinit be heplful?

naugtur commented 11 years ago

I guess not. I expected routechange to fire when hash changes too. And changing from / to /#pageB should also trigger a routechange for /. I know it's difficult, because inline pages have their ids in the data-url attribute (and that's why routechange on "pageB" worked) but I think there's a way to safely guess what's the path after hash has changed.