I am creating a pop up.I am using fancybox ,it is working fine when I include it normally in html as:
<script type="text/javascript">
$(document).ready(function($){
$.fancybox.open([{
content: $('<a href="http://www.google.com" target="_blank">Gmail</a>')
}]);
});
</script>
But when i write the same quote in drupal_add_js its not working:
drupal_add_js('jQuery(document).ready(function(){
$.fancybox.open([{
content: $("<a href=\'http://www.google.com\' target=\'_blank\'>Gmail</a>")
}]);
});','inline');
I am passing it as inline java script,someone can tell me what is the error due to which its happening.I have included the fancybox js and css.
I believe drupal set noConfilct on jQuery so you'll have to set the parameter of the ready function to $
drupal_add_js('jQuery(document).ready(function($){
$.fancybox.open([{
content: $("<a href=\'http://www.google.com\' target=\'_blank\'>Gmail</a>")
}]);
});','inline');
It finally worked for me. I explicity called the js file using drupal_Add_js function and rest all code was same. Its working absolutely fine as required by me. Thanks a lot for help.
drupal_add_js('jquery.fancybox.js');
drupal_add_js('http://code.jquery.com/jquery-1.7.2.js');
drupal_add_js('jQuery(document).ready(function(){
$.fancybox.open([{
content: $("<a href=\'http://www.google.com\' target=\'_blank\'>Gmail</a>")
}]);
});', 'inline');