Skip to content
Browse files

Adding doOnce and initialize.

  • Loading branch information...
1 parent 3bd223a commit ef8c6231950f958f6484b1dc3bff3a143d19b8ac @cohitre committed Jan 2, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 jquery.cohitre.js
View
22 jquery.cohitre.js
@@ -0,0 +1,22 @@
+(function ($) {
+
+/*
+ * $.initialize(selector, callback, args...);
+ */
+$.initialize = function (selector) {
+ var args = $.makeArray(arguments).slice(1);
+ $(function () {
+ $.fn.doOnce.apply($(selector), args);
+ });
+};
+
+/*
+ * $(selector).doOnce(someFunction, arg1, arg2, ....);
+ */
+$.fn.doOnce = function (callback) {
+ var args = $.makeArray(arguments).slice(1);
+ this.length && callback.apply(this, args);
+ return this;
+};
+
+})(jQuery);

0 comments on commit ef8c623

Please sign in to comment.
Something went wrong with that request. Please try again.