{"id":5284992,"date":"2014-09-12T00:53:23","date_gmt":"2014-09-12T00:53:23","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/passing-parameters-to-modal\/"},"modified":"2016-08-22T01:25:29","modified_gmt":"2016-08-22T01:25:29","slug":"passing-parameters-to-modal","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/passing-parameters-to-modal\/","title":{"rendered":"Passing parameters to modal"},"content":{"rendered":"<p>I&#8217;m trying to use Easy Modal to take a set of content generated by another plug-in (Google Calendar Events) and allow people to click to get more details about an event. I&#8217;m trying to implement the solution described here:<\/p>\n<p>https:\/\/wordpress.org\/support\/topic\/help-me-60?replies=9<\/p>\n<p>I was having problems getting it to work, so to simplify the issue, I just tried to create a button that does what I want. <\/p>\n<p>I added the following JavaScript to the theme&#8217;s custom JS function:<\/p>\n<pre><code>jQuery(&#039;.eModal-1&#039;).click(function(e){\n  e.preventDefault();\n  var $this = $(this);\n  var $modal = $(&#039;#eModal-1&#039;);\n  var instructor = $this.data(&#039;instructor&#039;);\n  $(&#039;span.instructor&#039;, $modal).text(instructor);\n  $modal.emodal(&#039;open&#039;);\n});<\/code><\/pre>\n<p>The button is:<\/p>\n<pre><code>&lt;button class=&quot;eModal-1&quot; data-instructor=&quot;foobar&quot;&gt;Click Me&lt;\/button&gt;<\/code><\/pre>\n<p>And, the modal itself is:<\/p>\n<pre><code>&lt;p&gt;Instructor &lt;span class=&quot;instructor&quot;&gt; &lt;\/span&gt;&lt;\/p&gt;<\/code><\/pre>\n<p>The way I understand this, the value &#8220;foobar&#8221; should be passed to eModal, which should put it in the span tag. <\/p>\n<p>The button and the JS both appear on the page. When I click the button, the modal comes up, and &#8220;Instructor&#8221; appears, but &#8220;foobar&#8221; doesn&#8217;t. <\/p>\n<p>http:\/\/bacafest.com\/test-page\/<br \/>\nClick on &#8220;Click Me&#8221;<\/p>\n<p>WordPress 4.0, X Theme 2.4.0.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/easy-modal\/<\/p>\n","protected":false},"template":"","class_list":["post-5284992","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5284992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5284992\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5284992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}