Problems with wiselinks and turbolinks

Asked

Viewed 111 times

-1

I need that, after clicking a button, a modal appears, inside this modal there is a populated form (or not) with Rails objects. The problem is that I can’t change the Accept header to js so that Rails renders (doesn’t print the code on the screen but runs) a .js.erb. To solve this, I decided to put on the one button data-remote=true so that .js.erb would run but the page would not be reloaded, but I need to change the url and so I wanted to use wiselinks with the attribute data-push=true, But the two of them together doesn’t work. Can someone help me with the modal problem or can help me how I make the modal appear with the remote and change the url with the pushState???

PS. the ideal would be that when clicking the button the modal appeared (with the content under the previous action) and when accessing the url directly the modal was also rendered (with a content of another action below)

  • You try to solve this by using the history api of Html5, http://diveintohtml5.info/history.html ?

1 answer

1

You can create a function that shows the modal, download the JSON from the object and do this via JS:

function mostraModal(obj) {
  alert('Objeto: ' + obj.nome);
}

Of course instead of alert() you can use some more elaborate plugin, using HTML, etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.