Re: Spark condition on control status

31 views
Skip to first unread message

Rob G

unread,
Oct 27, 2012, 5:45:00 AM10/27/12
to spar...@googlegroups.com
Hi yoli,

Think if the condition inside a Spark if block as C# rather than JavaScript. It gets evaluated before the page is ever sent down to the browser, so it doesn't really make sense to put JavaScript in there and expect it to be evaluated at a later stage. You should rather have "daily" as a boolean property on your viewmodel, and then use that to render the view like this for example:

<viewdata model="MyNameSpace.MyViewModelClass" />

<if condition="Model.IsDaily" >
   <!-- rendered if true -->
</if>

Cheers,
Rob

On Fri, Oct 26, 2012 at 8:37 AM, yoli <leon8...@gmail.com> wrote:

I wanted to conditionally show part of HTML, but why can't I do this in Spark?

                  <if condition="document.getElementById('daily').checked">

or this, if I'm using Propotype

                  <if condition="$('daily').checked">

--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spark-dev/-/KCZLOdWopY0J.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages