ifad / data-confirm-modal

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

Changing confirmation text only works once #66

Closed marat-y closed 4 years ago

marat-y commented 6 years ago

Hello!

I'm trying to dynamically change confirmation text. But dialog actually changes only the first time I change data-confirm value. Is there anything else I'm doing wrong or some event I need to trigger for this to work correctly?

I'm using v.1.3.0.

UPD. Updating to 1.6.1 made no effect.

vjt commented 6 years ago

Hi, sorry for the late reply.

When using data- attributes, the modal is built once by buildModal and then cached into the confirm-modal data attribute by getConfirmModal.

If you want to keep using data- attributes, you can use the newly exposed .getConfirmModal() to get the modal object, and then:

$(..).getConfirmModal().find('.modal-body p').text('new text')

Otherwise, you can use the window.dataConfirmModal() API, that creates new modals every time it is called.

JamesPlayer commented 4 years ago

Hi, it looks like $(..).getConfirmModal() is not in the latest release (v1.6.2). Could you please release it when you get a chance?

vjt commented 4 years ago

Hi @JamesPlayer,

1.6.3 has been pushed to rubygems. Thanks for the heads up.

jamgregory commented 4 years ago

@vjt - please could you push the latest version to npmjs? It doesn't look like it has been updated there. Thanks! :+1:

Halloran commented 2 years ago

same here...