13

I see this has been asked before but I dont see any solutions:

So Im using Cordova 2.5 to build an iPad app on iOS 6.1.2

My app.coffee:

jQuery ->
    class window.AppRouter extends Backbone.Router
        routes: {
            '': 'index',
            ':parent/:child/': 'childView',
            ':id/': 'detailView',
        },

        index: =>
            $("#navbar .title").text("Flight Centre's Choices")
            view = new fc.main.View
            view.render()

        childView: (parent, child) =>
            view = new fc.main.View(parent:parent, child:child)
            view.render()

        detailView: (id) =>
            view = new fc.main.Detail(id:id)
            view.render()

    window.app = new AppRouter();
    Backbone.history.start();

The first index view loads successfully and displays as it should

Now clicking on one of the links to lets say open childView, it fails to load the page:

2013-03-20 16:56:13.684 Flight[1158:907] Resetting plugins due to page load.
2013-03-20 16:56:13.689 Flight[1158:907] Resetting plugins due to page load.
2013-03-20 16:56:13.694 Flight[1158:907] Failed to load webpage with error: Frame load interrupted

the link the user clicks on looks like this':

/#/foo/bar/

Everything works as expected in Chrome browser on my mac.

I dont know whats happening here!!

Harry
  • 13,091
  • 29
  • 107
  • 167

2 Answers2

35

Damn this waisted allot of time, the answer was so dumb and simple.

Rather than having the links in the html as :

/#/foo/bar/

It should just be

#/foo/bar/

this makes sense, with the leading / the page will reload, and thats why I got that error.

Hope it helps someone

Harry
  • 13,091
  • 29
  • 107
  • 167
  • 3
    Yep, had the same problem with Phonegap 3 and AngularJS... thank God for Google! – JP Richardson Dec 06 '13 at 00:33
  • For those that may come later, this did *not* solve my problem when linking via ng-href. Invoking $location.path('/route_name') via a method call in ng-click did work, however... Curiouser and curiouser... – ericpeters0n May 07 '14 at 22:16
  • In my case, I was already using #/ in all the links. Even though I tried both #/ and /#/ the only thing that worked was leaving the links as they were and removing – Bernat Feb 15 '17 at 16:02
0

I could solve it by using window.location.hash

Simon Hoss
  • 562
  • 1
  • 3
  • 7