开发者

"Not a function" javascript error (jquery floatingbox plugin)

I always was wondering why the floatingbox plugin was not able to put a div container at the bottom right of my page. http://www.phpletter.com/Demo/Jquery-Floating-Box-Plugin/ Today I checked my site with firebug, and found this error:

$("#thediv").floating is not a function

ON LINE: $("#thediv").floating({targetX:"right", targetY:"bottom"});

Here is the code:

<script type="text/javascript" src="/js/jquery.js"></script>
<script type="te开发者_如何学Goxt/javascript" src="/js/jquery.floatingbox.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(
        function(){
            jQuery("#thediv").floating({targetX:"right", targetY:"bottom"});
        }
    );
</script>

The floating function is created like this in the plugin:

jQuery.fn.floating = function(options)
{
    return jQuery(this).each(

        function(i)
        {
            var nextIndex = 0;
            for(var index in funcFloating)
            {
                nextIndex = parseInt(index);
            }
            funcFloating[nextIndex + 1] = {};
            funcFloating[nextIndex + 1].box = this;
            funcFloating[nextIndex + 1].obj = new floatingBox(this, options, (nextIndex + 1));
            funcFloating[nextIndex + 1].func = function(){ funcFloating[nextIndex + 1].obj.doFloat(); };
            if (document.layers)
            {
                funcFloating[nextIndex + 1].obj.init();
            }else
            {

                funcFloating[nextIndex + 1].obj.init();
                funcFloating[nextIndex + 1].obj.initSecondary();
            }

        }
    );
};

What can I do to fix this? When looking at the source code on the plugin's example page, I see the same code is used as on my own page.

If this was a conflict error of some sorts, wouldn't the first use of "$" (in "$(document)") already trigger an error?


Well, are you sure that the floating() function has been defined on $.fn, the jQuery object prototype?

  1. Make sure that you've properly included the floatingbox js file
  2. Make sure it's after the jquery include so the $ object exists at the time the plugin tries to extend the prototype.

Edit: According to the code sample, it is being included in the right order. Do you have a link so we can see the problem?


This plugin? If so, take a look at the source of that page for an example. One:

$('#moving_box1').floatingBox({
    scale : 0.3,
    blur : true,
    isText : false,
    xOffset : 235,
    yOffset: 185,
});

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜