Archive

Archive for the ‘Javascript’ Category

JQuery Mini-tips

March 6th, 2009 fbis No comments

Get a DOM object from a JQuery obj

$('#' + id).get(0); //get the dom object from the jquery wrapper

Only include object if JQuery is available

//only include if jquery is available
if (typeof jQuery != 'undefined') {
   //class goes here
}

Read more…

Categories: JQuery, Javascript Tags:

Simple JQuery Treeview

January 30th, 2009 fbis 2 comments

I’ve been trying to write my first JQuery plug in and went for a tree view because I need to display some nested data. Nothing complicated and more about trying to understand the JQuery plug in structure really. It’s pretty well commented so I won’t explain it :D

Read more…

Categories: JQuery Tags: , ,

Hiding UniqueIds in css class names

January 27th, 2009 fbis No comments

I always have a unique id in my databases for each row. When passing this to objects for javascript to manipulate I add it to the class string as ‘id_1′ so I can easily retrieve it later. The GetIds function below returns an array with the id pulled out. It also handles multiple ids in the format of ‘id_name_1′ so we can do something like ‘block id_1 id_Page_1′

Read more…

Categories: Javascript Tags:

Check if an image exits.

January 26th, 2009 fbis Comments off

Javascript can be used to check if an image exist. An AJAX call cannot be used, because cross-site calls are not supported. However, the javascript Image object can be used for this purpose.

var img = new Image();
 
 <a href="http://www.fruitbatscode.com/javascript/check-if-an-image-exits#more-4" class="more-link">Read more...</a>
Categories: Javascript Tags: