{"id":134,"date":"2014-08-24T01:15:14","date_gmt":"2014-08-24T01:15:14","guid":{"rendered":"https:\/\/www.lianeallen.com\/home\/?p=134"},"modified":"2014-09-10T23:28:55","modified_gmt":"2014-09-10T23:28:55","slug":"bootstrap-js-modal-dialog","status":"publish","type":"post","link":"https:\/\/www.lianeallen.com\/home\/2014\/08\/bootstrap-js-modal-dialog\/","title":{"rendered":"Bootstrap JS Modal Dialog"},"content":{"rendered":"<p>It&#8217;s terrible (and annoying) UX when you&#8217;re trying to take an action, only to be sent through a whole slew of other pages, or worse, to be logged in, then redirected to a completely unrelated page. <\/p>\n<p>However, I need donors to log in before donating, so the donation can be properly managed (oh, those banks and their rules&#8230;). So, I want to have a modal login dialog, that&#8217;s activated by any donation level button on the projects page, that returns the user gracefully to the project page when login is complete. <\/p>\n<p>How to do this turns out to be way less obvious than I expected it to be, so I was very happy to come across this fantastic post on implementing a bootstrap JS modal popup:<\/p>\n<blockquote><p><a href=\"http:\/\/www.whatibroke.com\/?p=395\" title=\"http:\/\/www.whatibroke.com\/?p=395\" target=\"_blank\">http:\/\/www.whatibroke.com\/?p=395<br \/>\n<\/a><\/p><\/blockquote>\n<p>The guy&#8217;s blog is great &#8211; clear, concise, and full of stuff that didn&#8217;t work, and how he made it work. <\/p>\n<p>I think of bootstrap as a layout\/design thing, not a functionality thing, so I never even considered that it might have a .js modal dialog option. <\/p>\n<h3>Speaking of Which: If Your Modal Closes Instantly&#8230;<\/h3>\n<p>If you follow that tutorial and find that the dialog pops up and immediately disappears, check your application.js file. <\/p>\n<p>The tutorial tells you to require bootstrap-modal in your applicaiton.js. This is unnecessary if you&#8217;ve already required bootstrap, since it includes modal. If you do include it, the modal code will be called twice &#8211; once via the main bootstrap.js and once via the bootstrap-modal.js &#8211; in rapid succession, which will dismiss the modal almost as soon as it is drawn.<\/p>\n<p>Just delete the require line for bootstrap-modal, and it should work just fine.<\/p>\n<h3>But Wait! There&#8217;s More!<\/h3>\n<p>My ultimate goal is to have the user log in (<em>achievement: unlocked<\/em>), the dialog automatically close when login completes, and the parent page automatically refresh when the dialog closes. The code in the tutorial doesn&#8217;t do that. I&#8217;ll put up a post with lots of pretty code snippets when I&#8217;ve got it all working.<\/p>\n<h3>UPDATE<\/h3>\n<p>Apparently, <a href=\"https:\/\/github.com\/twbs\/bootstrap\/issues\/2380\">it&#8217;s a total nuisance<\/a>, due to bootstrap folks deciding not to attach click events to buttons within the modal in v3, so I&#8217;ll find a different solution, at some point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s terrible (and annoying) UX when you&#8217;re trying to take an action, only to be sent through a whole slew of other pages, or worse, to be logged in, then redirected to a completely unrelated page. However, I need donors to log in before donating, so the donation can be properly managed (oh, those banks &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.lianeallen.com\/home\/2014\/08\/bootstrap-js-modal-dialog\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bootstrap JS Modal Dialog&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":137,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/posts\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/comments?post=134"}],"version-history":[{"count":9,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/posts\/134\/revisions"}],"predecessor-version":[{"id":190,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/posts\/134\/revisions\/190"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/media\/137"}],"wp:attachment":[{"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/media?parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/categories?post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lianeallen.com\/home\/wp-json\/wp\/v2\/tags?post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}