Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

MR, Ajax & JSGenerator

with one comment

A friend stabbed and asked me

How do I control ajax delete scenario where I want to remove table row if deleted is successful otherwise I will alert user that they can’t delete this particular record?

Sound very familiar right? The beauty of MR is it leverage your existing web development skills, and just believe me when I tell you so.

Now let take a look at how MR JSGenerator would solve the problem described above, let see our action code:


public void AjaxTest(int id){
if (id < 0) { PropertyBag["err"] = "Woop! what are you talking about?"; } // for some reason I had to flow the code down PropertyBag["id"] = id; } ... [/sourcecode] Now the view part (*.brailjs) [sourcecode language='javascript'] if IsDefined("err"): page.Alert(err) else: page.Alert("Id = " + id) end [/sourcecode] No hack no tweak but what about the result? well it safe to try that yourself at home. Is there any JSGenerator in ASP.NET MVC? I doubt that. Edit: I suppose to be able to do cooler code, but this bug prevented me http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-504

Advertisements

Written by Chorn Sokun

November 7, 2008 at 11:15 am

Posted in MonoRail, Tips & Tricks

Tagged with ,

One Response

Subscribe to comments with RSS.

  1. រីករាយណាស់ដែលបានមកចូលក្នុងប្លុកបង។ សូមក្ដីរាប់អានផងណាបង ទើបតែស្គាល់រសជាតិប្លុកនិងគេទេណាបង

    Rath

    November 23, 2008 at 9:26 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: