Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails remote conflicts with bootstrap remote modal

I'm having a problem with Twitter bootstrap & Rails data-remote link.

I load the modal content with data-remote="/path/to/data". Everything works as I want BUT create two requests.

= link_to '#myModal', 'Click here', data: {toggle: 'modal', remote: '/path'}

The first is rails data-reomte who makes a request to the page I'm at and after that bootstrap makes his requets and the modal is shown.

Is there any way I can turn of rails remote on specified links or is it actually another problem?

like image 233
sandelius Avatar asked May 03 '13 16:05

sandelius


1 Answers

According to Bootstrap doc on Modal: http://twitter.github.io/bootstrap/javascript.html#modals

if you're using the data api, you may alternatively use the href tag to specify the remote source. An example of this is shown below:

<a data-toggle="modal" href="remote.html" data-target="#modal">click me</a>

So, your request can be fulfilled by disable Rails UJS data api and use Bootstrap's. Like this

<a data-toggle="modal" href="remote.html" data-target="#modal" 
data-remote="false">click me</a>

In your case. The server side code

= link_to 'Click here', '/path_for_bootstrap',
    data: {toggle: 'modal', remote: false, target: "#myModal"}

Update Or better, no need to define remote at all because nobody need it, either Bootstrap or UJS!

= link_to 'Click here', '/path_for_bootstrap',
    data: {toggle: 'modal', target: "#myModal"}
like image 167
Billy Chan Avatar answered Oct 29 '22 09:10

Billy Chan