Thursday, July 25, 2013

jQuery custom plugins

This article is a very lucid explanation of creating jQuery plugins. It explains the importance of $.fn and shows the use of  $.extend and $.isFunction well. Obviously one can look at the source of jQuery but the author of the article has done a good job. The key points Are:

Wrapping your plug-in in (function( $ ){ // plugin goes here })( jQuery ); is desirable.

Don’t redundantly wrap the this keyword in the immediate scope of your plug-in’s function. Pay attention to this and $(this) in the article.

Payattaention to object chaining aspect by returning this. Unless you’re returning an intrinsic value from your plug-in, always have your plug-in’s function return the this keyword to maintain chainability.

Pass your plug-in settings in an object literal that can be extended over the plug-in’s defaults. Look at $.extend in the article.

Don’t clutter the jQuery.fn object (incidentally pronounced “jQuery effin”) with more than one namespace per plug-in.

Always namespace your methods, events, and data.

This good practice should get you going.

Sunday, July 7, 2013

activity android:name=”.ExampleActivity” or activity android:name=”ExampleActivity”

Should there be a dot in the activity name in the AndroidManifest file and, if so, why? The question had exercised my mind and this is a clear explanation. In short, prefixing with dot prefixes the activity name with package and application name. For itisconsulatants we have com.itisconsultants.myapp.ExampleActivity when we say .ExampleActivity.

Stackflow too has great explanation.