jquerywordpresstwitter-bootstraptwitter-bootstrap-3contact-form-7

Make Contact Form 7 trigger a bootstrap modal


I have a Bootstrap based theme and I'd like the success message of Contact Form 7 trigger the Bootstrap Modal (i.e. a "popup").

I tried having the Modal sample code on my page

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
          </div>
          <div class="modal-body">
            ...
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

And I assumed it would work by placing the following string in the "Additional Settings" of Contact Form 7:

on_sent_ok: "$('#myModal').modal(options)"

Unfortunately that does not result in any visible effect. Just the normal success message seems to be suppressed (it's not showing).

I would appreciate any ideas on the topic, as it doesn't seem to be featured anywhere.


Solution

  • hmm, on other examples I have seen people using jQuery(), also the "options" argument will likely be undefined. try this:

     on_sent_ok: "jQuery('#myModal').modal()"