Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Can you apply visible binding based on the data currently being bound? -


i'm trying set content in template visible if item being rendered "current item".

here code far, want able render part of inner template if data item being rendered has id == window.viewmodel.activeobject.

<section data-bind='template: { name: "categorytemplate", foreach: categories }'></section>  <script type="text/html" id="categorytemplate">     <section>         <h2>${name}</h2>         <section data-bind='template: { name: "objecttemplate", foreach: objects }'></section>     </section> </script> <script type="text/html" id="objecttemplate">     <article>         <h3>${name}</h3>        (only render if object rendered has id equal viewmodel.activeobject)         {{html text}}      </article> </script> <script>     $(document).ready(function(){         window.viewmodel = { categories : <asp:literal runat="server" id="literaljson" />,             activecategory: ko.observable(0),             activeobject: ko.observable(0)         };          ko.applybindings(window.viewmodel);     }); </script> 

how go doing that?

you'll want use {if}{/if}

<script type="text/html" id="objecttemplate">     <article>         <h3>${name}</h3>         {if $item.data.id === viewmodel.activeobject()}         {{html text}}         {/if}     </article> </script> 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -