Saturday 15 June 2013

javascript - How to use Sessions and Templates to show/hide elements? -


I have 7 questions that I personally want to ask once on the page. I have every one of them in the same template and I know that I should use session-set-session.get every time to show / hide them but I do not really know how to do it, Example and how can not get it. In this way I structured the layout template with 7 questions.

  & lt; Template name = "layout" & gt; {{#if before}} {{& gt; SubmitProblem}} {{/ if}} {{#if second}} {{ First of all, when the page opens, it needs to be displayed ...} {} / and then I tried to do this with sessions, but there is no conjecture ...  

 < Code> Meteor.startup (function () {session .set ("first", true);}); Template.layout.events ({'click .btn1': function () {session .set ("first", wrong); session .set ("second", true);}});          

It seems that using jQuery to show / hide the show with the show: Block / nobody is easy ?

If you want to hide items on the page, you should define and .hide or .hidden class These should use CSS. Hide / hide items using JQuery Show / Hide Bad behavior is considered that you should present all hidden templates that are wrapped with a hidden class. The first template you want to show will not be a hidden class.

CSS:

  .hidden {display: none; }  

template:

  & lt; Template name = "layout" & gt; {{& Gt; SubmitProblem}} {{& gt; SubmitWhy}} ... & lt; / Template & gt; & Lt; Template Name = "Submit Problem" & gt; & Lt; Div id = "submit-problem" & gt; ... & lt; / Div & gt; & Lt; / Template & gt; & Lt; Template Name = "Submit" & gt; & Lt; Div id = "submit-why" category = "hidden" & gt; ... & lt; / Div & gt; & Lt; / Template & gt;  

  Template.layout.events ({click '.btn1': function AddClass ('hidden'); $ ('# submit-why'). RemoveClass 'hidden') () {// removeClass () / addClass () $ ('# submit-problem') ;}});  


No comments:

Post a Comment