We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36552
    • 32 Posts
    I have a registration and event management snippet that I am in the process of refactoring/rewriting in order to clean up some garbage that's built up over the past year and improve the performance. At the moment, I'm trying to get backbone to handle the display and CRUD (using Slim to handle the routing for the PHP/MySQL end)

    The problem I'm having is related to Friendly URLs and the relationship of a Backbone route or link ('cars/:id') to the url of the resource in use on the site (http://sitename.com/registration/event-manager.html?event=CarManager). I've managed to create a couple of .htaccess RewriteRules for some jQuery AJAX functions in the past and it would seem to be necessary here, though I can't seem to get to the correct method.

    My question is, has anybody successfully implemented Backbone.js on Evo with Friendly URLs turned on?

    If so, how did you organize the app and get your routes working?

    This question has been answered by etal. See the first response.

      • 36552
      • 32 Posts
      Nobody has figured out how to work with Backbone routes and friendly URLs in MODx yet? That doesn't seem possible.
      • discuss.answer
        • 9130
        • 171 Posts
        I have a very good understanding of both modx & backbone but I'm not sure I understand what you are trying to achieve. Normally with backbone you map many urls to one server/html page and let backbone handle the specifics on the client side.

        Do you plan to use backbone on all your modx pages or just some? Do you have a specific set of urls you want backbone to work with? Can you explain in detail what you are trying to do?
          • 36552
          • 32 Posts
          etal, thanks for responding. I think I've figured it out, or at least this part of the problem. Your suggestion of mapping to a single page is what needed to be done. Got that a few days ago.

          The app is a rebuild of a event registration snippet with numerous functions dependent on the access level of the user. I'm using WebLoginPE to handle the registration/login side of things and am trying to limit the snippet to permissions and database CRUD functions and let Backbone handle the user interactions.

          I ended up over-thinking the basics when my first couple of attempts didn't work. Took a day or two away from it and came back, realizing the URL needed to be included with the hash. Instead of trying to get href="#vehicles/<id>" to bypass the Friendly URLs, used the path to the page, like this "registration/event.html#vehicles/<id>" and am able to now deal with everything using standard Backbone routes.