Aralot (aralot) wrote in changelog,
Aralot
aralot
changelog

[ljcom] r10159: LJINT-365: fn.input from jquery_fn

Committer: szhirkov
LJINT-365: fn.input from jquery_fn
U   trunk/htdocs/js/partners/placeholder.js
Modified: trunk/htdocs/js/partners/placeholder.js
===================================================================
--- trunk/htdocs/js/partners/placeholder.js	2011-03-03 05:05:29 UTC (rev 10158)
+++ trunk/htdocs/js/partners/placeholder.js	2011-03-03 05:31:23 UTC (rev 10159)
@@ -59,5 +59,20 @@
 				})
 				.trigger('blur');
 		});
-	};	
+	};
+
+	$.fn.input = function (fn) {
+		return fn ? this.each(function() {
+						var last_value = this.value;
+						jQuery(this).bind("input keyup paste", function(e) {
+							// e.originalEvent use from trigger
+							if (!e.originalEvent || this.value !== last_value) {
+								last_value = this.value;
+								fn.apply(this, arguments);
+							}
+						});
+					}) 
+					: this.trigger("input");
+	};
+		
 })(jQuery);

Tags: aralot, js, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments