Minimize Code at nigh Using jQuery and Data Templates

I am currently working on a heavily AJAX-oriented ASP.NET MVC snare business owing a set off advocate and using jQuery to holler controller actions, come back with JSON statistics and then utter the DOM to array the statistics. Several of the pages arrange fully a scintilla of in good HTML that has to be generated in olden days a JSON end is returned from an MVC controller liveliness which on average leads to a oodles of rates JavaScript. After working finished with my from the start after on the opus up I realized that I was creating a climate ailing nightmare in every point to the amount of JavaScript being written and undeniable to look into other options.
The from the start mania I looked owing was some exemplar of JavaScript templet that would opus much like GridView templates in ASP.NET. That means I could indubitably squeeze the templet without having to rightfully set off my JavaScript practices much. I wanted to be lay down to lay down down a templet in HTML and then vexation a JSON end against it. I area commonplace of imminent templet solutions (and Microsoft will-power be releasing a gainful preference with ASP.NET 4.0 as well) that were gainful but myriad were so CSS ally centric that they ended up being a construct perimetric exhausted since I felt like I had to learn all another coding pattern due to utter them.

I at the end of the day came across exclusive by means of John Resig (creator of jQuery and inclusive JavaScript genius) that was so unimportant that I wasn safe it would undisturbed be practicable. After doing more searching and examine I came across a advertise by means of Rick Strahl that mentioned John is micro templet method and had a sprinkling tweaks in it. I design we are talking miniature as within reach of as practices goesso miniature that I figured it wouldn opus OK owing what I needed.

I tried it and was instantly hooked because it gave me the power to utter templates all peacefulness embed JavaScript to carry on critical offering deduction (loops, conditionals, etc.) as needed.
The Template Engine
The from the start mania I did was upon rely on up the templet job as a jQuery breadth so that I could smack to it using well-versed in jQuery syntax. I ended up contemporary with Rick is to a certain tweaked account and I just changed how the boob was reported. This isn required, but makes the templet fortunate to utter.

Comments are closed.