The name is MooTools, a very cool Javascript Library with object oriented and Ajax support. It simplifies the way you write your scripts because it has a very simple syntax and a lot of features integrated (like effects, Drag and drops, scrolls, Tooltips, etc, etc).
To test the framework, I started yesterday an Star Rating control in ASP.NET. I Clearly needed 2 things
The first was easy. I made a little search and found 2 very simple that i recommend: Komodomedia and pmob.
For this example I used the second. Both are well done, so i just picked one of them.
The second: do some code using mootools (Also very easy like is expected of any javascript framework)).
First Step: The creation of the control
The first thing to do is to to create a control that renders the star rating. The method GetRating is something abstract because, according to your implementation (and context of usage) this information will come from a specific place.
Let's just suppose that the we are in a context of an blog and the rating goes to a database and get's the average rating of the current post.
NOTE: for test proposes the method can return the value '3' (just to see some stars).
After create this control, create and aspx and insert insert the control into an ASPX test page. Don't forget to add the css of the star rating to the aspx. This css is available at http://www.pmob.co.uk/temp/star-rating.htm ( or simply download the zip at the end of the page
).
then compile and run the project. You should see something like this:
Second Step: The javascript
Now that we have the control running, we need to add to each star and event onclick so we can handle the user rating. To do this, we will the following script:
The Ajax type has an event named "update". This is very useful because you can simply put the html element you want there (In the example above I inserted the element "ratingMessage') and the response of the request will simply be inserted into the element.
After this step you will not be able to see anything moving (yet!) because the page that handles the ajax request, Formatter.aspx, isn't created.
Third Step: Process the Ajax request
Finally the page responsible for receiving the ajax request, the Formatter.aspx (to make the example simple, I used an aspx page but you can also any type of file).
The page only receives the value of rating (to simplify the example) and returns a text indicating which rating we choose.
You can download this example here
Just a FYI…
As of mootools version 1.1, mootools is not compatible with MS AJAX. There are conflicts in the native array extensions, specifically in the Array.each extension. Using both together will result in errors. Version 1.0 works fine.
It’s too bad really, ‘cuz mootools is by far the best js framework I’ve worked with, and I’ve used them all…
BTW…I realize your example isn’t using MS AJAX. I just wanted to let ppl know in case they get all excited to use mootools and they also use MS AJAX…
Yes the example only uses mootools. I’m actually a little septic about MS Ajax. It’s all cool and easy to use, but the network traffic it generates must be enormous (viewstates, etc).
This is just me talking. Although i already used MS Ajax (in the beta version), I didn’t made any network analysis to the ajax request/response traffic traffic (maybe that should be something I should do before say anything else about MS Ajax traffic
).
But the point here was showing that mootools Ajax framework is very easy to use and that we can control all the Ajax requests and responses in a very simple an elegant way.
[...] Moooo what? (via DotNetKicks) [...]