Note that there are some explanatory texts on larger screens.

plurals
  1. PORJS and Observer for Showing/Hiding a DIV
    primarykey
    data
    text
    <p>I have an RJS template that I use to essentially do the following:</p> <p>Fade out a submitted form Show a response popup div Bring up a new form using a partial</p> <p>What I want to do is have the RJS hold off on bringing up that second form until the user has clicked the "x" button on the popup.</p> <p>The RJS code so far is as follows:</p> <pre><code>unless @actor.health &lt;= 0 || @actor.finished page.visual_effect(:fade, "act_form", :duration =&gt; 0.5) if @actor.acts.last.decision.consequence &amp;&amp; @actor.acts.last.decision.consequence != "" page.insert_html :after, 'act_form_wrapper', :partial =&gt; 'consequence' page.assign 'popup', true end page.delay(1) do page.replace_html("act_form", :partial =&gt; 'act_form') if @prompt.decisions.count &gt; 1 page.assign 'decEmpty', true else page.assign 'decEmpty', false end if @actor.play.comment_req page &lt;&lt; 'document.getElementById("act_comment").value = ""' end page.visual_effect(:appear, "act_form", :duration =&gt; 0.5) end page.replace_html("scores", :partial =&gt; 'scores') else flash[:notice] = 'This game is finished. How did you do?' page.redirect_to(@actor) end </code></pre> <p>And the popup div looks like:</p> <pre><code>&lt;span class="close_consequence"&gt;&lt;%= link_to_function image_tag('close.png', :alt =&gt; 'close'), "$('.consequence_popup').remove(); popup=false;" %&gt;&lt;/span&gt; </code></pre> <p>What I had in mind was for the "popup" Javascript variable to be used by some kind of while loop or an observer that would hold off if it was true, and then run when it was false. not sure if this is even feasible or if I should be doing this entirely differently. The RJS stuff is still quite a mystery to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload