<div dir="ltr">I wrote an fbjs library to help speed up development of some of my applications. I plan to have some sort of &quot;official&quot; release with a blog entry and github repository at some point, but I thought you guys might want to have it earlier.<br>
<br>It&#39;s still a work in progress. I&#39;ve been using every method at least once in my application but it&#39;s still possible there is a bug or two I missed. Let me know if you find any bugs.<br><br><br>Javascript (stand alone)<br>

<a href="http://pastie.org/256150">http://pastie.org/256150</a><br><br>Rails Helpers:<br><a href="http://pastie.org/256153">http://pastie.org/256153</a><br><br><br>Examples of use:<br>&nbsp;&nbsp;&nbsp; Select Element<br>&nbsp;&nbsp;&nbsp; $(&#39;noelement&#39;);<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Select 2 Elements<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;,&#39;test2&#39;);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Select elements by class<br>&nbsp;&nbsp;&nbsp; getElementsByClass(&#39;test2c&#39;)<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Select elements by tag<br>&nbsp;&nbsp;&nbsp; getElementsByTagName(&#39;strike&#39;)<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Use Javascript version of .map<br>&nbsp;&nbsp;&nbsp; [&#39;a2&#39;,&#39;b2&#39;].toSource() == map([&#39;a&#39;,&#39;b&#39;], function(val) { return val+2 }).toSource()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Recurse through the dom under a selected element and return nodes for which test is true as an array<br>
&nbsp;&nbsp;&nbsp; collect($(&#39;test1&#39;), function(element){ return (element.getClassName() == &#39;test2c&#39;) })<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Check if an element is visible<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).visible()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Hide an element<br>
&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).hide()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Show an element<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).show()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Toggle element visibility<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).toggle();<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Remove an element from the dom<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).remove();<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Get a hash of calculated element dimensions width/height as integers<br>&nbsp;&nbsp;&nbsp; $(&#39;test1&#39;).getDimensions()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Update remote<br>&nbsp;&nbsp;&nbsp; Update: function(target_element, response_type, action_path, callbacks, post_parameters)<br>
&nbsp;&nbsp;&nbsp; (FBML/RAW)&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Ajax.Update(&#39;test1&#39;, &#39;FBML&#39;, &#39;http://...&#39;,{ success: function(){} })<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Load Remote<br>&nbsp;&nbsp;&nbsp; Load: function(response_type, action_path, callbacks, post_parameters)<br>
&nbsp;&nbsp;&nbsp; (FBML/RAW/JSON)&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Ajax.Load(&#39;JSON&#39;,&#39;http://...&#39;,{ success: function(result){console.log(result)} }, {&#39;json&#39;:test_content})<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Remote Form<br>&nbsp;&nbsp;&nbsp; &lt;%= fbjs_form_remote_tag :update =&gt; &#39;a&#39;, :html =&gt; { :action =&gt; &#39;<a href="http://inigral.ath.cx:3003/javascript_test/test_helpers_res">http://inigral.ath.cx:3003/javascript_test/test_helpers_res</a>&#39; }, :response =&gt; &#39;RAW&#39; %&gt;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;test_hidden&quot; value=&quot;test value&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;checkbox&quot; name=&quot;test_box&quot; checked=&quot;true&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input name=&quot;test_input&quot;/&gt;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; value=&quot;submit&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br>&nbsp;&nbsp;&nbsp; &lt;div id=&quot;a&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; In place Edit<br>&nbsp;&nbsp;&nbsp; Will post: {txt_field_name:&#39;Text inside editable field&#39;}<br>
&nbsp;&nbsp;&nbsp; &lt;%= fbjs_in_place_editor_text_div(&#39;txt_field_name&#39;, &#39;Text inside editable field&#39;, &#39;http://...&#39;, { :class =&gt; &#39;test&#39; }) %&gt;<br>&nbsp;&nbsp;&nbsp; &lt;a href=&quot;#&quot; onclick=&quot;txt_field_name_editor.edit()&quot;&gt;edit&lt;/a&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;a href=&quot;#&quot; onclick=&quot;txt_field_name_editor.save()&quot;&gt;save&lt;/a&gt;<br></div>