Trying to upgrade jQuery 1.4.2 plugin to 1.8.2 but get syntax error, unrecognized expression

[SOLVED]

See below for more details.

Line

var maxUl = $(objUl+'[rel="'+maxItems+'"]');

should be

var maxUl = $(objUl.attr('id')+'[rel="'+maxItems+'"]'); 

to function with the current jQuery 1.8.2 implementation.


First of all, thanks for taking the time to look at my problem with me. I looked through many other questions and, as far as I can tell, this problem is not the same.

I get this error from firebug when I try to load the jQuery plugin on the page: Error: Syntax error, unrecognized expression: [object Object] [rel = "7"]

Note. The plugin works fine when starting jQuery 1.4.2, but running multiple jQuery instances is not an option for this project.

The plugin I'm trying to implement can be found here and downloaded here

, js (jquery.dcdrilldown.1.2.js)

// Get level of largest sub menu
var maxUl = $(objUl+'[rel="'+maxItems+'"]');
var getIndex = findMaxIndex(maxUl);

,

var maxUl = $(objUl+'[rel="'+maxItems+'"]');

firebug findMaxIndex().

HTML

JS

$(function() { // Drill down menu
  $('#drilldown').dcDrilldown({
    speed           : 'slow',
    saveState       : true,
    showCount       : false,
    linkType        : 'breadcrumb'
});

HTML ul

<div class="graphite dd-container">
<ul id="drilldown">
<li><a href="#">Home</a>
  <ul>
    <li><a href="#">Page 1</a></li>
    <li><a href="#">Page 2</a></li>
    <li><a href="#">Page 3</a></li>
    <li><a href="#">Page 4</a></li>
  </ul>
</li>
<li><a href="#">Products</a>

, , , .

+5
2

, objUl. , , , . , , ( [object Object]).

, objUl , , .attr('id').

Edit

var maxUl = $(objUl+'[rel="'+maxItems+'"]'); 

var maxUl = $(objUl.attr('id')+'[rel="'+maxItems+'"]'); 
+6

jQuery 1.10.4 make-it works finee

// var maxUl = $(objUl+' [rel="'+maxItems+'"]');
var maxUl = $(objUl.html()+' [rel="'+maxItems+'"]');

//$('#'+idHeader+' a').live('click',function(e){
$('#'+idHeader).on('click','a',function(e){
0

All Articles