Closed dimroc closed 9 years ago
Thanks for pointing this out, I will investigate and get back to you today or tomorrow.
I spent some time looking into this and here's what I found.
POST
requests always had turboboostComplete
called.GET
requests don't have turboboostComplete
called because of how Turboboost handles GET requests, which you can see here:
https://github.com/waymondo/turboboost/blob/530f0c5313c347f484ab070186625c1f92aa6829/app/assets/javascripts/turboboost.js.coffee#L72-74Both GET
and POST
forms though were disabling the submit button and when you clicked the browser back-button, the button was still disabled. This was a bug in my eyes. I just improved this behavior and allowed it to be disabled.
Hopefully that solves your issue. If you are still having an issue with events getting called, give me your example and I'll look into it further.
You're right, the turboboostComplete does get invoked on a fresh page for me.
I'm under the impression that the turboboostComplete callback should re-enable to form before navigating to the new page here: https://github.com/waymondo/turboboost/blob/530f0c5313c347f484ab070186625c1f92aa6829/app/assets/javascripts/turboboost.js.coffee#L55
thus making the back button work. Either way, the Turboboost.handleFormDisabling
will definitely unblock me, thanks a lot.
Here is my form if you still need it:
= simple_form_for(@gift, url: redemption_path(@gift.raw_redemption_token), turboboost: true) do |f|
= f.hidden_field :selected_product_id, value: product.id
%h4.title= product.name
.summary= product.summary
.view= link_to "View Details", "", data: {toggle:"modal", target:"#product-model-#{product.id}"}
%hr.bottomless
= f.submit "Receive This Gift »", class: 'receive'
The reason the form isn't re-enabled in that link is because the redirect URL is returned as a header and then Turbolinks needs to fetch the page. If the submit button was re-enabled at that moment, before the Turbolinks.visit
finishes for the redirect URL, the user could re-submit the form which is unideal. Clicking on the back-button from the new page will re-enable the submit tag now though. It sounds like the update should get you where you need to be then.
The ajax:complete callback never invokes turboboostComplete. 99% this doesn't matter because you just go to the next page via Turbolinks.visit. But before navigating to the new page, turboboost disables the form, so if a user clicks the back button, the form will remain disabled. This doesn't happen 100% of the time though...
Perhaps it's an issue with ajax:complete and rails.