ifad / data-confirm-modal

Makes Rails' link_to confirm: 'foo' build a Bootstrap Modal instead of calling the browser's confirm() API.
MIT License
271 stars 115 forks source link

Triggering twice without refresh doesn't work #12

Closed dereklucas closed 8 years ago

dereklucas commented 10 years ago

I have a subscribe/unsubscribe link that looks a little like this:

<%= link_to 'Subscribe', subscribe_deck_path(@deck), class: "subscribe_action subscribe #{@deck.subscribed? ? '' : 'active'}", remote: true %>
<%= link_to 'Unsubscribe', unsubscribe_deck_path(@deck), method: :delete, data: { confirm: "Are you sure?" }, class: "subscribe_action unsubscribe #{@deck.subscribed? ? 'active' : ''}", remote: true %>

Switching the display state of the links based on subscription status. If I Unsubscribe once, I get the correct modal. If I then subscribe and unsubscribe again without refreshing the page, I get the browser dialog. It's as if the event is being attached with jQuery's one() function..

I'm also using https://github.com/jschr/bootstrap-modal if that's a conflict.

vjt commented 10 years ago

Hi!

We'll try to reproduce this issue and we'll also investigate how much this project and @jschr's bootstrap-modal overlap - it may be a good idea to merge the two!

Thanks for reporting this to us :smile:,

~Marcello

~ vjt@openssl.it ~ http://sindro.me/

On 08 Apr 2014, at 20:50, Derek Lucas notifications@github.com wrote:

I have a subscribe/unsubscribe link that looks a little like this:

<%= link_to 'Subscribe', subscribe_deck_path(@deck), class: "subscribe_action subscribe #{@deck.subscribed? ? '' : 'active'}", remote: true %> <%= link_to 'Unsubscribe', unsubscribe_deck_path(@deck), method: :delete, data: { confirm: "Are you sure?" }, class: "subscribe_action unsubscribe #{@deck.subscribed? ? 'active' : ''}", remote: true %> Switching the display state of the links based on subscription status. If I Unsubscribe once, I get the correct modal. If I then subscribe and unsubscribe again without refreshing the page, I get the browser dialog. It's as if the event is being attached with jQuery's one() function.. I'm also using https://github.com/jschr/bootstrap-modal if that's a conflict.

— Reply to this email directly or view it on GitHub.

allpumpedup commented 10 years ago

Works beautifully! Thank you

magicmarkker commented 9 years ago

I've been able to reproduce this in a rails app that doesn't use bootstrap modal. On confirm, it doesn't continue to the link provided in the href as well.

<a class="btn btn-default " data-confirm="Are you sure you want to make this Poll visible? Doing so will wipe all answers." href="http://bedev.local:3000/workrooms/1/surveys/9/visible">
  <span class="icon icon_mbm-visible-on visible active-on"></span>
  <span class="icon icon_mbm-visible visible active-off"></span>
  <span>Visible to Workgroup</span>
</a>
kntmrkm commented 8 years ago

any update?

vjt commented 8 years ago

Hi @kntmrkm, thanks for the heads up. I will try to give this a spin in the coming days.

caycehouse commented 8 years ago

modal-content is cleared after model is dismissed, therefore there is nothing to display.

vjt commented 8 years ago

Thanks everyone involved in tracking this down. Please try the latest v1.2.0 and let me know if it works for you :-)

vjt commented 8 years ago

Moreover, please see http://jsfiddle.net/zpu4u6mh/ for an example using Rails remote links. Please let me know if there are still scenarios breaking the code expectations.