TypeError: $(…).dotdotdot is not a function?

匿名 (未验证) 提交于 2019-12-03 10:03:01

问题:

A multipart question here, but I'll start with the main problem.

  • I'm having issues getting a jQuery plugin to work on a site I'm designing. FireBug is telling me that "TypeError: $(...).dotdotdot is not a function". However, I've loaded the Jquery libraries in the correct order. Does anyone know why my plugin is generating that error?

  • Piggybacking off of that... I'm trying to use 'dotdotdot' to truncate metadata pulled from a Tumblr RSS feed. Am I properly selecting that element in the script, or should I be pointing it at a different div/ID? Currently it's looking for "#miniblog_d".

Thanks everyone for any assistance! This one has been stumping me for a few weeks honestly. If you review the file you'll notice I'm loading a king's ransom of jQuery libraries, and if there's a way to just load one, please let me know. I haven't gotten any other scripts to work by just loading the latest jQuery file at the top.

Thank you!!

edit: I'm sorry - totally blanked here - live example is at http://tinychivalry.com/cjyoga/

回答1:

You're loading more than one version of jQuery on your page. You're actually doing it like this:

version X of jQuery dotdotdot plugin ... ... version Y of jQuery ... ... 

What's happening is that the dotdotdot plugin is "attached" to the prototype of version X of jQuery, but then you load version Y, which overwrites version X, and makes everything attached to it no longer accessible, including your dotdotdot plugin.

Here's your header code:

<script type="text/javascript" src="custom_js/jquery-1.9.1.js"></script> <script type="text/javascript" language="javascript" src="custom_js/jquery.dotdotdot.min.js"></script>  <link rel="stylesheet" type="text/css" media="screen, print, projection"  href="sg_reset.css" /> <link rel="stylesheet" type="text/css" media="screen, print, projection"  href="drag_system.css" /> <!-- --> <link rel="stylesheet" type="text/css" media="screen, print, projection"  href="cjyogaweb_common.css" /> <link rel="stylesheet" type="text/css" media="screen, print, projection"  href="cjyogaweb_common_textstyles.css" /> <!-- --> <!--  -->  <script type="text/javascript" src="sg_jscripts/jquery_1.5.2_min.js"></script> 

See how you're loading 1.9.1 and then 1.5.2 after it? That is your problem. Please only use a single version of jQuery, there are several reasons why it's ridiculous to do otherwise.

EDIT I just re-read your post and saw that you are indeed loading a crapload (technical term) of various versions of jQuery. This is, in no uncertain terms, wrong.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!