Activate your free membership today | Log-in

Tuesday, September 25th, 2007

Reiterate: Symbol#to_proc for JavaScript

Category: JavaScript, Library, Prototype

<>p>James Coglan has ported ideas from ideas from Ruby's Symbol#to_proc and Methodphitamine to create Reiterate, a library for Prototype.

The library means that instead of code like this:

JAVASCRIPT:
  1.  
  2. var value = radioGroup.find(function(radio) {
  3.   return radio.checked;
  4. }).value;
  5.  
  6. var divs = someDivs.findAll(function(div) {
  7.   return div.hasClassName('myClass') && div.visible();
  8. });
  9.  

you can write:

JAVASCRIPT:
  1.  
  2. var value = radioGroup.find('checked').value;
  3.  
  4. var divs = someDivs.findAll({hasClassName: 'myClass', visible: true});
  5.  

Download Reiterate.

Related Content:

  • Ajax seen solving JavaScript issues for RIA
    For rich Internet application (RIA) development, Ajax is doing for JavaScript what JavaScript couldn't do alone, the author argues. "The browser wars...
  • FAQ: Lotus Notes, Domino and JavaScript
    Caught in a JavaScript jam? Before posing a question to our SearchDomino.com experts, check out our list of frequently asked questions on JavaScript...
  • Junk JavaScript?
    Should JavaScript and HTML be replaced with "proper" languages that might give more bang for the buck in rich Internet applications (RIAs)? One reader...
  • JavaScript Learning Guide
    This SearchDomino.com guide introduces you to JavaScript in a Notes/Domino environment, explains best practices and pitfalls to avoid and provides...
  • JavaScript Library in a Notes database
    Do you need the same JavaScript code in many Notes forms? This tip will shows you how you can maintain JavaScript code in only one...

Posted by Dion Almaer at 8:47 am
14 Comments

+++--
3.3 rating from 24 votes

14 Comments »

Comments feed TrackBack URI

Enumerable on steroids! This syntax is truly amazing…

Comment by kangax — September 25, 2007

Looks like the first steps in making prototype operate like jquery.

Comment by Glen — September 25, 2007

forget jqueery.

Comment by Mike — September 25, 2007

have you guys tried moo?

sorry, couldn’t resist.

Comment by Steve — September 25, 2007

@Glen, you must mean more like ruby. This has nothing todo with another framework, ktnxbye

Comment by Trulli — September 25, 2007

@Steve: how can I go to my boss and tell him we should try a library called ‘Moo Tools’? You guys need a better name to be taken seriously.

Comment by Les — September 25, 2007

@Les, i was just kidding about the moo comment. i think the framework wars are pretty silly (as is the name “moo”)

Comment by Steve — September 25, 2007

@Glen: indeed, I had some strange déja vu feeling ;-)

Comment by Frank Thuerigen — September 25, 2007

@Steve and @Frank: mootools = my object oriented tools, if your boss makes his decisions based on how cool of a name something has, then I suggest you find a new job … since the company won’t be around for much long.

Comment by Marat Denenberg — September 25, 2007

Woopsie … I need more sleep … above comment for Steve and Les … sorry Frank … blah! Ajaxian needs a better comment system, like the one on Engadget, where you can reply to comments.

Comment by Marat Denenberg — September 25, 2007

jquery

Comment by Micox — September 25, 2007

@Marat

Considering that Ruby on Rails is usually used based on the name or hype rather than an actual business case, maybe judging by a name isn’t so bad. ;-)

Plus, mootools sounds pretty cool.

Comment by Andy Kant — September 25, 2007

You could just call it “moot-ools”. Now that is just Moot ools of fun… :)

Comment by Mike Kidder — September 25, 2007

Thanks for that
ha ha

Comment by Remedies — December 8, 2008

Leave a comment

You must be logged in to post a comment.