Posts

Showing posts with the label events

THE LONDON BREWERS ALLIANCE SHOWCASE

Image
M&I spent Friday evening drinking many fine ales from across the capital. There's plenty to say about our experience but right now the words are being quelled by the locally brewed hangover. For more pictures please click here

jQuery.live() – event binding to AJAX loaded elements

jQuery.live() function was introduced in jQuery version 1.3. It makes it easy to dynamically bind events to DOM elements that have not yet been created. In other words, it helps you to easily attach events to AJAX loaded elements that match your criteria. NOTE: If for some reason you are using old versions of jQuery, prior to 1.3, you will need to use event delegation or another method as

jQuery.live() – event binding to AJAX loaded elements

jQuery.live() function was introduced in jQuery version 1.3. It makes it easy to dynamically bind events to DOM elements that have not yet been created. In other words, it helps you to easily attach events to AJAX loaded elements that match your criteria. NOTE: If for some reason you are using old versions of jQuery, prior to 1.3, you will need to use event delegation or another method as

Create callback functions for your jQuery plugins & extensions

Most of the time custom jQuery plugins and extensions that we create do not use a callback functions. They usually simply work on DOM elements or do some calculations. But there are cases when we need to define our own custom callback functions for our plugins. And this is especially true when our plugins utilize AJAX querying. Let’s say our custom jQuery extension gets data by making some

Create callback functions for your jQuery plugins & extensions

Most of the time custom jQuery plugins and extensions that we create do not use a callback functions. They usually simply work on DOM elements or do some calculations. But there are cases when we need to define our own custom callback functions for our plugins. And this is especially true when our plugins utilize AJAX querying. Let’s say our custom jQuery extension gets data by making some

Identifying & locating mouse position in jQuery

While writing the next jQuery tutorial I needed to identify and locate where the mouse was on the page. Tracking mouse position on the page with jQuery is easy. You don’t need to check what browser the script is running like it is used to be with plain JavaScript. To identify where the mouse is in jQuery all you have to do is to read event object’s .pageX and .pageY properties. Example: $().

Identifying & locating mouse position in jQuery

While writing the next jQuery tutorial I needed to identify and locate where the mouse was on the page. Tracking mouse position on the page with jQuery is easy. You don’t need to check what browser the script is running like it is used to be with plain JavaScript. To identify where the mouse is in jQuery all you have to do is to read event object’s .pageX and .pageY properties. Example: $().

Disable submit button on form submit

Form submission is one of the most used actions and double form submission is one of most occurred problems in web development. Rather than dealing with this problem server side, eating up your CPU process time, it is much easier and better to deal with this problem client side using JavaScript. When we talk javascript, what it a better way to write it other than using jQuery?! So this Friday’s

Disable submit button on form submit

Form submission is one of the most used actions and double form submission is one of most occurred problems in web development. Rather than dealing with this problem server side, eating up your CPU process time, it is much easier and better to deal with this problem client side using JavaScript. When we talk javascript, what it a better way to write it other than using jQuery?! So this Friday’s

Select text in input box on user select or focus

A colleague of mine who is not very javascript or for that matter jQuery aware asked me to help him to do a little trick with jQuery. He needed to select the contents of the input box when user selects it (when onfocus event is fired basically). Selecting a text in your inputbox on focus is easy and actually 3 lines of jQuery code, but it add a nice usability touch to your site. This “select all

Select text in input box on user select or focus

A colleague of mine who is not very javascript or for that matter jQuery aware asked me to help him to do a little trick with jQuery. He needed to select the contents of the input box when user selects it (when onfocus event is fired basically). Selecting a text in your inputbox on focus is easy and actually 3 lines of jQuery code, but it add a nice usability touch to your site. This “select all

Problems with jQuery mouseover / mouseout events

Today I have a quick note for you that will probably save you time someday. Basically it’s a workaround for a bug when you have parent element with children elements and parent element has mouseover or mouseout event. Moving your mouse over children elements may fire mouseout event of their parent. This is caused by event bubbling / propagation and if you would like to have a quick solution just

Problems with jQuery mouseover / mouseout events

Today I have a quick note for you that will probably save you time someday. Basically it’s a workaround for a bug when you have parent element with children elements and parent element has mouseover or mouseout event. Moving your mouse over children elements may fire mouseout event of their parent. This is caused by event bubbling / propagation and if you would like to have a quick solution just

Only the last element is bound/inserted/etc. in your javascript code’s “for” loop

There is a common problem when you use javascript for loop to bind an event function or add a class that comes from looping selection’s attributes. To make clear what I mean consider this example: var lis = $('ul li'); for (var i = 0; i var id = lis[i].id; lis[i].onclick = function () { alert(id); }; } // All li's get and alert the last li's id There is

Only the last element is bound/inserted/etc. in your javascript code’s “for” loop

There is a common problem when you use javascript for loop to bind an event function or add a class that comes from looping selection’s attributes. To make clear what I mean consider this example: var lis = $('ul li'); for (var i = 0; i var id = lis[i].id; lis[i].onclick = function () { alert(id); }; } // All li's get and alert the last li's id There is

Preload images with jQuery

Web2.0 came with AJAX and AJAX came with its own requirements and standards for web application developers. Now web applications are more like desktop applications with a lot of options, dialogs and more. If you have developed AJAX application with different user controls you surely loaded resources such images, other javascript files on demand. This helps you keep your application lightweight

Preload images with jQuery

Web2.0 came with AJAX and AJAX came with its own requirements and standards for web application developers. Now web applications are more like desktop applications with a lot of options, dialogs and more. If you have developed AJAX application with different user controls you surely loaded resources such images, other javascript files on demand. This helps you keep your application lightweight

How to disable all jQuery animations at once

Yesterday I came across jQuery.fx.off setting in jQuery documentation. It disables all jQuery animations effective immediately when you set it's value to true. Consider this code: jQuery.fx.off = true; $("input").click(function(){ $("div").toggle("slow"); }); Your div will be showed/hidden immediately without animation. One of the reasons (as documentation mentions) to disable animations

How to disable all jQuery animations at once

Yesterday I came across jQuery.fx.off setting in jQuery documentation. It disables all jQuery animations effective immediately when you set it's value to true. Consider this code: jQuery.fx.off = true; $("input").click(function(){ $("div").toggle("slow"); }); Your div will be showed/hidden immediately without animation. One of the reasons (as documentation mentions) to disable animations

Working with jQuery 1.3's new Event object (jQuery.Event)

To start, in jQuery 1.3 event object has been normalized and wrapped into jQuery.Event object. As it says in the documentation: "The event object is guaranteed to be passed to the event handler (no checks for window.event required)." Here is an jQuery.Event object overview: Attributes event.type event.target event.relatedTarget event.currentTarget