duanmen1887 2013-12-18 19:31 采纳率: 0%
浏览 32
已采纳

Javascript无法在php中正常工作

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.

  • 写回答

2条回答 默认 最新

  • dssu33392 2013-12-18 19:35
    关注

    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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法