【问题标题】:Ajax Tooltip using Mootools not working使用 Mootools 的 Ajax 工具提示不起作用
【发布时间】:2011-10-12 08:38:18
【问题描述】:

我想使用以下脚本创建 Mootools ajax 工具提示

new MooTooltips({
                        extra:{  
                            0: {
                                'id':this.id,
                                'ajax':'http://www.fesn.cz/communities/tip.php',
                                'ajax_message': 'Loading... please wait.',
                                'position':1,
                                'sticky':false
                            }
                        },
                        ToolTipClass:'ToolTips',    // tooltip display class
                        toolTipPosition:-1, // -1 top; 1: bottom - set this as a default position value if none is set on the element
                        sticky:false,        // remove tooltip if closed
                        fromTop: 0,        // distance from mouse or object
                        fromLeft: -55,    // distance from left
                        duration: 300,        // fade effect transition duration
                        fadeDistance: 20    // the distance the tooltip starts the morph
                    });

    }

脚本演示在这里,

http://jsfiddle.net/kyathi/mHEjV/.

背后的想法是当 mouseenter 每个可提示的类都会显示一个 ajax 工具提示。但是当鼠标悬停在div上时,脚本第一次调用ajax脚本失败,之后会调用。

有解决错误的想法吗?

谢谢

【问题讨论】:

    标签: javascript ajax mootools mootools-events


    【解决方案1】:

    我发现了toolTipPosition:-1 而不是它显示工具提示。但是没有对齐。

    http://jsfiddle.net/mHEjV/1/

    【讨论】:

      【解决方案2】:

      $$ 函数始终返回一个数组。您将事件添加到数组而不是数组元素上。你需要做一个循环或者使用each()方法:

      $$('div.tippable').each(function(div){
          div.addEvents({
          mouseenter:function(){
          ...
      

      http://jsfiddle.net/mHEjV/2/

      而且它不会在 jsfiddle 中工作,因为 ajax 调用使用不同的域。

      http://en.wikipedia.org/wiki/XMLHttpRequest#Cross-domain_requests

      祝你好运

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多