Nico Ritsche
2007-Dec-24 08:52 UTC
[Masterview-users] conditionally hiding a tag and form_remote with parameter
Hi, I''m trying to conditionally hide a div tag. The only way I could get it working is like this: <div mv:if="!@open_tasks.empty?"> *some html *</div> <div style=''display:none'' mv:else=""> * same html* </div> However, I don''t like it, as I have to repeat the same html twice. Is there a better way of doing it? Another thing: Can I create a form_remote_tag with a parameter using mv:form_remote? So far I only made it working using form_remote_tag directly like this: {{{ form_remote_tag :html => { :id => ''order_form_open'' } do}}} But I obviously like to avoid this as it shows up on the page. Kind Regards, Nico -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20071224/ff8a5d88/attachment.html
Jeff Barczewski
2007-Dec-24 18:37 UTC
[Masterview-users] conditionally hiding a tag and form_remote with parameter
To conditionally set the a div to a style of hidden you can simply use mv:attr <div mv:attr=":style => #{(@open_tasks.empty?) ? ''display:none'' : '' ''}"> some html </div> basically just using an inline conditional to determine what to set the style to If you were wanting to do this a lot, then a custom directive could be created to simplify the syntax. As for the form_remote you can do something like this <form mv:form_remote=":html => { :id => ''order_form_open'' } "> </form> We haven''t updated the form directives to use the block style yet, but the above should do what you need. Have a Merry Christmas! Jeff -- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy http://inspiredhorizons.com/ On Dec 24, 2007 2:52 AM, Nico Ritsche <nico.ritsche at googlemail.com> wrote:> Hi, > > I''m trying to conditionally hide a div tag. The only way I could get it > working > is like this: > > <div mv:if="!@open_tasks.empty?"> > > *some html > > *</div> > > <div style=''display:none'' mv:else=""> > > * same html* > > </div> > > However, I don''t like it, as I have to repeat the same html twice. Is > there a > better way of doing it? > > Another thing: Can I create a form_remote_tag with a parameter using > mv:form_remote? So far I only made it working using form_remote_tag > directly like this: > > {{{ form_remote_tag :html => { :id => ''order_form_open'' } do}}} > > But I obviously like to avoid this as it shows up on the page. > > Kind Regards, > Nico > > _______________________________________________ > Masterview-users mailing list > Masterview-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/masterview-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20071224/a32812cd/attachment-0001.html