Skip to main content

Posts

Showing posts from February, 2009

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 add more items to the existing jQuery selection

There are occasions when you have already selected elements and need to add more items to it. Imagine you have selected different items and have jQuery selection object. For example: var elms = $('#elem, .items'); Now, you need to add more new items (DOM nodes) to your section. Let’s say you want to add .otherItems to your elms selection. You could achieve it by using one of these methods:

How to add more items to the existing jQuery selection

There are occasions when you have already selected elements and need to add more items to it. Imagine you have selected different items and have jQuery selection object. For example: var elms = $('#elem, .items'); Now, you need to add more new items (DOM nodes) to your section. Let’s say you want to add .otherItems to your elms selection. You could achieve it by using one of these methods:

jQuery For Firebug

We all use Firebug and sometimes need jQuery in pages that don’t already have it. In such cases you can use the following javascript code or the bookmarklet that would insert jQuery into the page’s DOM on the fly. Thus making jQuery available for use in Firebug. Load jQuery to Firebug Here are two options to jQuerify any page. The code is taken from a jQuerify javascript code snippet by John

jQuery For Firebug

We all use Firebug and sometimes need jQuery in pages that don’t already have it. In such cases you can use the following javascript code or the bookmarklet that would insert jQuery into the page’s DOM on the fly. Thus making jQuery available for use in Firebug. Load jQuery to Firebug Here are two options to jQuerify any page. The code is taken from a jQuerify javascript code snippet by John

jQuery 1.3.2 Released

It seems that the jQuery’s new maintenance release 1.3.2 has not got enough coverage on other sites and thus a lot of developers still don’t know of it’s release. It was released on the 20 of February and can be downloaded here: Minified (gzipped 19KB) For development (120KB) Notable changes: Faster :hidden/:visible selectors; Faster .height()/.width() methods; Faster selectors

jQuery 1.3.2 Released

It seems that the jQuery’s new maintenance release 1.3.2 has not got enough coverage on other sites and thus a lot of developers still don’t know of it’s release. It was released on the 20 of February and can be downloaded here: Minified (gzipped 19KB) For development (120KB) Notable changes: Faster :hidden/:visible selectors; Faster .height()/.width() methods; Faster selectors

Add table row using jQuery and JavaScript

I noticed that there are a lot of developers who need to dynamically add a new table row to the bottom of their tables. I wrote a little javascript function that takes your jQuery selection of tables and dynamically adds a table row at the bottom of them.jQuery add table row function definition:/* Add a new table row to the bottom of the table */ function addTableRow(jQtable){

Add table row using jQuery and JavaScript

I noticed that there are a lot of developers who need to dynamically add a new table row to the bottom of their tables. I wrote a little javascript function that takes your jQuery selection of tables and dynamically adds a table row at the bottom of them.jQuery add table row function definition:/* Add a new table row to the bottom of the table */ function addTableRow(jQtable){

How to use YUICompressor to compress your javascript code?

Since writing on this blog I posted two jQuery plugins and I needed to compress my js files. So as jQuery documentation suggests I used YUICompressor. YUICompressor is javascript and CSS file/code compressor written in Java language. So to run one yourself you will need JRE installed on your machine. Then call this command: java -jar /path/to/yuicompressor.jar path/to/file.js -o path/to/

How to use YUICompressor to compress your javascript code?

Since writing on this blog I posted two jQuery plugins and I needed to compress my js files. So as jQuery documentation suggests I used YUICompressor. YUICompressor is javascript and CSS file/code compressor written in Java language. So to run one yourself you will need JRE installed on your machine. Then call this command: java -jar /path/to/yuicompressor.jar path/to/file.js -o path/to/

Font cleartype problems with fadeIn() and fadeOut() in Internet Explorer 7 (IE7)

Have you ever noticed whenever you use jQuery's fadeIn() and fadeOut() functions your text will become edgy. Mozilla and other seem to be rendering fine (not sure about IE6). Anyway, to solve this problem you need to remove the filter attribute from the DOM element that you have faded in/out.For example:// This causes this text glich $("#message").fadeIn(); // This will fix it

Font cleartype problems with fadeIn() and fadeOut() in Internet Explorer 7 (IE7)

Have you ever noticed whenever you use jQuery's fadeIn() and fadeOut() functions your text will become edgy. Mozilla and other seem to be rendering fine (not sure about IE6). Anyway, to solve this problem you need to remove the filter attribute from the DOM element that you have faded in/out.For example:// This causes this text glich $("#message").fadeIn(); // This will fix it

New code highlighter for Blogger.com

Hi everyone. I've spent almost a whole day updating all my posts here on jquery-howto.blogspot.com with jQuery and javascript code. I am using lightweight Google Code Prettify to highlight my code. Here is an example of the new highlighter: function JavascriptFunction() { // Comment example var myVariable; var privateMethod = function(){ }; return myVariable; } // jQuery code

New code highlighter for Blogger.com

Hi everyone. I've spent almost a whole day updating all my posts here on jquery-howto.blogspot.com with jQuery and javascript code. I am using lightweight Google Code Prettify to highlight my code. Here is an example of the new highlighter: function JavascriptFunction() { // Comment example var myVariable; var privateMethod = function(){ }; return myVariable; } // jQuery code

Automatically add table row count column to your tables with jQuery rowCount plugin

Some time ago I wrote a javascript code that automatically adds table row count column to your tables. And now I thought I would compile a jQuery plugin and submit it to the jQuery plugins repository. You can download jQuery rowCount plugin. The script takes into consideration your table header's row and column spans. Features: Gracefully degrade for those browsers that do not support

Automatically add table row count column to your tables with jQuery rowCount plugin

Some time ago I wrote a javascript code that automatically adds table row count column to your tables. And now I thought I would compile a jQuery plugin and submit it to the jQuery plugins repository. You can download jQuery rowCount plugin. The script takes into consideration your table header's row and column spans. Features: Gracefully degrade for those browsers that do not support

How to get a YouTube video screenshot image (thumbnail) URL using JavaScript

YouTube is a great video service by Google. As with any other product Google makes it easy to use its content on your own site. You can embed a YouTube video on your own site or query YouTube API (if you have a developer key). But what if you don't want to embed a flash video player and you only need an image of the video. The following function returns a YouTube video's thumbnail URL. Nothing

How to get a YouTube video screenshot image (thumbnail) URL using JavaScript

YouTube is a great video service by Google. As with any other product Google makes it easy to use its content on your own site. You can embed a YouTube video on your own site or query YouTube API (if you have a developer key). But what if you don't want to embed a flash video player and you only need an image of the video. The following function returns a YouTube video's thumbnail URL. Nothing

How to set custom rules in jQuery Validation plugin for fields that have a period "." in their names

We all love and use jQuery Validation plugin. For basic forms it does a great job and works flawlessly 80% of the time. But we all work on different kinds of projects and validation requirements change project to project. jQuery Validation is a very flexible plugin and provides a way to easily define your own validation rules. You can read more about jQuery Validation plugin and custom

How to set custom rules in jQuery Validation plugin for fields that have a period "." in their names

We all love and use jQuery Validation plugin. For basic forms it does a great job and works flawlessly 80% of the time. But we all work on different kinds of projects and validation requirements change project to project. jQuery Validation is a very flexible plugin and provides a way to easily define your own validation rules. You can read more about jQuery Validation plugin and custom

5 easy tips on how to improve code performance with huge data sets in jQuery

Sitting on jQuery's support mailing list I noticed that developers use jQuery with huge data sets and their code becomes very slow. Examples would be generating very long tables with a lot of rows using AJAX to get JSON data. Or iterating through a long (very long) list of data, etc. So I compiled a list of 5 easy tips on how to improve your code performance while working with huge data sets in

5 easy tips on how to improve code performance with huge data sets in jQuery

Sitting on jQuery's support mailing list I noticed that developers use jQuery with huge data sets and their code becomes very slow. Examples would be generating very long tables with a lot of rows using AJAX to get JSON data. Or iterating through a long (very long) list of data, etc. So I compiled a list of 5 easy tips on how to improve your code performance while working with huge data sets in

How to check jQuery version?

Sometimes you need to know what is the jQuery version that your script is working with. This maybe useful in you jQuery plugins, so your code can utilize the jQuery version specific code or maybe your code is running in some environment that already has jQuery embedded in, for example Drupal CMS. Anyway, here are two ways you can check the current jQuery version. // Returns string Ex: "1.3.1" $

How to check jQuery version?

Sometimes you need to know what is the jQuery version that your script is working with. This maybe useful in you jQuery plugins, so your code can utilize the jQuery version specific code or maybe your code is running in some environment that already has jQuery embedded in, for example Drupal CMS. Anyway, here are two ways you can check the current jQuery version. // Returns string Ex: "1.3.1" $

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

Why should I include all my CSS files before jQuery?

The simple answer is: "Because you have to". Since jQuery version 1.3 jQuery does not make sure all of your CSS files are loaded before it fires .ready() event. Here is an excerpt from jQuery 1.3 release notes: The ready() method no longer tries to make any guarantees about waiting for all stylesheets to be loaded. Instead all CSS files should be included before the scripts on the page.

Why should I include all my CSS files before jQuery?

The simple answer is: "Because you have to". Since jQuery version 1.3 jQuery does not make sure all of your CSS files are loaded before it fires .ready() event. Here is an excerpt from jQuery 1.3 release notes: The ready() method no longer tries to make any guarantees about waiting for all stylesheets to be loaded. Instead all CSS files should be included before the scripts on the page.