Is there a way to pass data to a modal?


Is there a way to create a modal once and open it multiple times and pass data to it each time? Say I have a table with a view button and when I click the button it calls to open the modal and I pass a JSON object to the modal with some data and it displays it.

This will save making multiple modals or changing the data in the DOM, this would make the code a lot cleaner and easier to understand.


The simplest way to do it is use jQuery.

function showModal(jsonObject) {     $('.ui.modal').find("input").val(jsonObject.value);     $('.ui.modal').modal('show'); }

The other and more elegant, but more complicated, is to use some JS framework with two-way binding, like VueJs, RiotJs, Backbone, Knockout etc.


Thanks for this reply, this isn’t a problem now since this was 4 month ago but this is a clever way of doing things! :slight_smile:


No problems, bro :joy: