Jquery: creating plugins

(function($){   $.fn.extend({     yourPluginName: function(options) {       var defaults = {         yourDefaults: ‘here’,                    anotherDefault:  ‘here’       }               // This way, what you pass as args overwrite your defaults:       var options =  $.extend(defaults, options);         returnselect;     […]

HTML5: Form fields

New attributes: autofocus=”autofocus” required=”required” oninput=”updateMessage(this)” /* You can run custom JS on input */ autocomplete=”on”  // Remembers what the users enter in the field before, and makes it available for autofill. If you want to create your own list of autofill values: Choose an animal: <input type=”text” name=”animal” list=”animals” /><br /> <datalist id=”animals”> <option value=”Moneky”> […]

node.js: how it is different from other web platforms

Node has a single thread, looping on itself to handle requests. Unlike PHP and other platforms, where each request spawn its own thread. This means: if a request modify a variable with global scope, the modified variable will be served in the next request. Node process in a nutshell: loop taking request (running in infinite […]

Rails and devise: building associations at record creation time

In your “create” method, on your controller: @search = current_user.searches.build(params[:search]) Assumes: current_user contains your user record (via devise) search, searches is the model of the record you are trying to create build is just there to marshal your posted form parameters, so no need to include them (RoR is magical like that) current_user.searches is building […]

Ruby On Rails: barebones site template from the ground up.

We are talking about quick demos, site bootstraping kind of deal here. So don’t expect robust, detailed explanations. Also, assuming you have Ruby / Rails / Git / postgresql / RVM (optional) installed. Barebones, cutting through most of the commands explanations. Aim to push site and ideas fast out there. $rails new first_app -d postgresql […]

Jquery mobile: the basics

Basic page structure: <div data-role=”page”> <div data-role=”header”></div> <div data-role=”content”></div> <div data-role=”footer”></div> </div>   Since links are internal (load a different part of your template), in order to call real external links, you need: Rel=”external” or data-ajax=”false” To implement a back button, you do: data-rel=”back” To implement dialogs (modals) instead of opening the page: data-rel=”dialog”, data-rel=”back” (to close […]