Wednesday, March 10, 2010

$(document).ready is not a function

$(document).ready is not a function

This error message appears only if another framework is in conflict with the almighty jQuery. For example You try to use Prototype/Scriptaculous for Lightbox but you also need something else, which requires jQuery.

Since no framework is compatible with another framework, you have to find a workaround to get things working.

And here comes jQuery in your help. The jQuery team was smart enough to realize that there will be conflicts between frameworks, especially the $ will cause massive headaches since it’s the basic of each framework. $ is the shortcut for the word “jQuery”

So, they invented jQuery.noConflict();. This will let you to replace the $ with the word jQuery, in all your code. So, when you need to call this: $(document).ready(function(){ … You simply replace the $ as I said above: jQuery(document).ready(function(){ …, don’t forget to call jQuery.noConflict(); before this.

So, when you use the noConflict() function, your code should look something like this:


<script type="text/javascript" src="JScripts/lightbox/prototype.js">
<script type="text/javascript" src="JScripts/lightbox/scriptaculous.js?load=effects,builder">
<script type="text/javascript" src="JScripts/lightbox/lightbox.js">

<script type="text/javascript" src="JScripts/jquery-1.2.6.min.js">
<script type="text/javascript" src="JScripts/jquery.linkselect.js">


<script type="text/javascript">

$(document).ready(function (){
$("#category").linkselect();
});


So now the above code block becomes



<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function (){
jQuery("#category").linkselect();
});




Tuesday, March 2, 2010

WAMP Enabling mod_rewrite

To enable mod_rewrite on Apache in WAMP (2.0) the http.conf file should be edited.

1) Left click on WAMP icon on the system tray
2) Click on Apache
3) Click httpd.conf

Find the following line
# LoadModule rewrite_module modules/mod_rewrite.so

and

Remove hash(#) to make the line
LoadModule rewrite_module modules/mod_rewrite.so

Restart the Apache server or WAMP as a whole can be restarted.

IIS7 and WAMP on same machine

To run Apache and IIS in same machine at same time. The port assigned to each server can be changed. I prefer changing IIS to port 81 and assign default http port i.e 80 to apache. The port changing in IIS7 and VISTA is done this way.

1) Run IIS
2) Click on default web site
3) Choose Edit Site ---> Bindings options from Actions pane in the right side.
4) click on the data available and click edit
5) change the port to 81 and host header to localhost

IIS 7 / ASP

To run the classic ASP in IIS 7 in addition to Internet information services, ASP must be installed which is done in this way.

1) Go to control panel --->programs and features
2) Click on Turn windows features on or off.
3) Select Internet information services --> World wide web services ---> Application development features -->ASP
4) The site can be run as an Application instead of virtual directory as in IIS6.0