{"id":8164,"date":"2015-11-28T07:09:14","date_gmt":"2015-11-28T07:09:14","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/28\/semantic-ui-meteor-modal-initalization-open-source-projects-semantic-org-semantic-ui\/"},"modified":"2022-08-30T15:42:25","modified_gmt":"2022-08-30T15:42:25","slug":"semantic-ui-meteor-modal-initalization-open-source-projects-semantic-org-semantic-ui","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/28\/semantic-ui-meteor-modal-initalization-open-source-projects-semantic-org-semantic-ui\/","title":{"rendered":"Semantic UI Meteor modal initalization-open source projects Semantic-Org\/Semantic-UI"},"content":{"rendered":"<p>I&#8217;m running Meteor with Semantic UI as a framework .<\/p>\n<p>I&#8217;ve got my main page on which I load X detail cards who all come from the same data source. All the detail cards have buttons, for example trash to remove the card.<\/p>\n<p>I&#8217;m confirming actions on the buttons through modals.<\/p>\n<p>I&#8217;ve got all of my modals in a separate template called modals.<\/p>\n<p>From my main page I load my modals:<\/p>\n<pre><code>{{&gt;modals}}\n<\/code><\/pre>\n<p>Inside my modals template I&#8217;ve got:<\/p>\n<pre><code>\n\n      \n          {{#with data}}\n        \n          \/\/HEADER\n        \n        \n              \/\/ DATA USAGE IN TEMPLATE\n              {{city}}\n        \n      \n\n<\/code><\/pre>\n<p>Above example is commented with <code>\/\/<\/code> and just a fraction of the real thing.<\/p>\n<p>The problem I&#8217;m running into is that I&#8217;m using the buttons on said card to call for the modal. The button eventhandler looks like:<\/p>\n<pre><code>Template.availablCard.events({\n    'click #checkmark': function () {\n        Session.set('data', this);\n        $('#takeModal').modal('show');\n    }\n....\n<\/code><\/pre>\n<p>and the modal template has a helper:<\/p>\n<pre><code>Template.modals.helpers({\n    data: function () {\n        return Session.get('data');\n    }});\n<\/code><\/pre>\n<p>The problem I am facing is that the modals never function properly the first time because a click hasn&#8217;t been registered yet and Session.data hasn&#8217;t been set yet.<\/p>\n<p>Is there a way to initialize the modals so they get loaded into the DOM, but still give them a data context?<\/p>\n<p>ps. I&#8217;ve chosen this approach so I don&#8217;t have to give every card it&#8217;s own modal.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m running Meteor with Semantic UI as a framework . I&#8217;ve got my main page on which I load X detail cards who all come from the same data source. All the detail cards have buttons, for example trash to remove the card. I&#8217;m confirming actions on the buttons through modals. I&#8217;ve got all of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-8164","post","type-post","status-publish","format-standard","hentry","category-semantic","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8164"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8164\/revisions"}],"predecessor-version":[{"id":8566,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8164\/revisions\/8566"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}