Remote Rails conflicts with remote modal bootstrap

I have a problem loading Twitter and a remote link with Rails data.

I load the modal content data-remote="/path/to/data" . Everything works the way I want, but let's create two queries.

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

Firstly, the data-reomte rails, which make a request to the page that I am on, and after this boot buffer do its details, and the modal is displayed.

Is there a way to turn the rails deleted by the specified links or is this another problem?

+6
source share
1 answer

According to the Bootstrap doc about Modal: http://twitter.imtqy.com/bootstrap/javascript.html#modals

If you are using api data, you can alternatively use the href tag to indicate the remote source. An example of this is shown below:

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

Thus, your request can be fulfilled by disabling the Rails UJS api data and using Bootstrap's. Like this

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

In your case. Server side code

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

Refresh . Or better, there is no need to define remote at all, because no one needs it, either Bootstrap or UJS!

 = link_to 'Click here', '/path_for_bootstrap', data: {toggle: 'modal', target: "#myModal"} 
+5
source

Source: https://habr.com/ru/post/944229/


All Articles