0

I'm using Ratchet 2.0 and BackBone.js to build a simple little PhoneGap application.

I want to use the Ratchet Modal functionality to modal in my terms and privacy policy, but I can't figure out how to access the modals from within my LoginView.js.

I've set up the correct structure in my file, but I don't know what to do inside the methods to access the Ratchet Modals.

app.views.LoginView = Backbone.View.extend({

    render: function () {
        this.$el.html(this.template());
        return this;
    },

    events: {
        "click .btn.pull-left": "back",
        "click .btn-link.terms": "terms",
        "click .btn-link.privacy": "privacy"
    },

    terms: function() {


    },

    privacy: function() {

    },

    back: function() {
        window.history.back();
        return false;
    }

});

In my index I have all the correct javascript files, although I'm not sure about the dependency order for the ratchet.js. I have it directly after jquery and before backbone.

<script src="http://app.mydomain.com/lib/jquery.js"></script>
<script src="http://app.mydomain.com/ratchet/ratchet.js"></script>
<script src="http://app.mydomain.com/lib/underscore.js"></script>
<script src="http://app.mydomain.com/lib/backbone.js"></script>
<script src="http://app.mydomain.com/lib/pageslider.js"></script>

<script src="http://app.mydomain.com/js/app.js"></script>
<script src="http://app.mydomain.com/js/utils/templates.js"></script>
<script src="http://app.mydomain.com/js/adapters/memory-adapter.js"></script>
<script src="http://app.mydomain.com/js/routers/AppRouter.js"></script>
<script src="http://app.mydomain.com/js/views/HomeView.js"></script>
<script src="http://app.mydomain.com/js/views/LoginView.js"></script>

I'm going to switch over to require.js once I get this actually working.

secondman
  • 3,233
  • 6
  • 43
  • 66

1 Answers1

0

You have to include the modals in your markup (e.g. template), and the opening method should just add the 'active' class to the modal, for example:

this.$('.modal.terms').addClass('active');
Roman
  • 13,100
  • 2
  • 47
  • 63
  • Actually the problem was that Ratchet functions are listening for the `touchend` event, so they weren't firing. Once I discovered this and changed them to `click` events the modals and popovers fire as expected. Thanks though :) – secondman Apr 14 '14 at 00:47