Tags » JQuery

setTimeout function jquery

setTimeout function can be used in many ways. Here a “div” is hidden after 5 seconds but it is called in a function. This will be hidden only if there is an request action. 45 more words

Jquery

Mobile Swipe with cut-off

Recently, I created a component to swipe a container which will reveal a hidden container. For this purpose, I used jQuery 1.11.0 and jQuery-mobile-1.4.4. I mentioned the detailed process under the code. 294 more words

Javascript

Basic Plugin Layout

/ Shawn Khameneh
// ExtraordinaryThoughts.com
 
(function($) {
	var privateFunction = function() {
		// code here
	}
 
	var methods = {
		init: function(options) {
			return this.each(function() {
				var $this = $(this);
				var settings = $this.data('pluginName');
 
				if(typeof(settings) == 'undefined') {
 
					var defaults = {
						propertyName: 'value',
						onSomeEvent: function() {}
					}
 
					settings = $.extend({}, defaults, options);
 
					$this.data('pluginName', settings);
				} else {
					settings = $.extend({}, settings, options);
				}
 
				// run code here
 
			});
		},
		destroy: function(options) {
			return $(this).each(function() {
				var $this = $(this);
 
				$this.removeData('pluginName');
			});
		},
		val: function(options) {
			var someValue = this.eq(0).html();
 
			return someValue;
		}
	};
 
	$.fn.pluginName = function() {
		var method = arguments[0];
 
		if(methods) {
			method = methods;
			arguments = Array.prototype.slice.call(arguments, 1);
		} else if( typeof(method) == 'object' || !method ) {
			method = methods.init;
		} else {
			$.error( 'Method ' +  method + ' does not exist on jQuery.pluginName' );
			return this;
		}
 
		return method.apply(this, arguments);
 
	}
 
})(jQuery);

“Send detailed email to parents” functionality on the Office Visits page

Remember to always back up your data before making any changes to it.
Always try out your customizations on a test server first, NOT the live one. 1,108 more words

JQuery

X+Y Position

Another Tricks that might work>

jQuery.fn.getCoord = function()
{
var elem = $(this);
var x = elem.offset().left;
var y = elem.offset().top;
console.log(‘x: ‘ + x + ‘ y: ‘ + y); 57 more words

X+Y Position

The below code will give you the X, Y coordinates of a mouse click within a given box. Removing all the stuff about the offset, you can easily get the X, Y coordinates of the click relative to the browser window. 26 more words

Is there a difference between $document.ready() & window.onload() ???

How $document.ready() is different from window.onload()

We often use window.onload() in javascript and $document.ready()
but there is quiet a difference between them both:

window.onload() () 216 more words

Javascript