Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to update a jQuery 1.4.2 plugin to 1.8.2 but getting Syntax error, unrecognized expression

[RESOLVED]

See below for question details.

The line

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

needs to be

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

to be functional with the current jQuery 1.8.2 implementation.


First of all thanks for taking the time to look at my issue with me. I've looked through many of the other questions and as best I can tell this issue isn't the same.

I'm getting this error from firebug when I attempt to load a jQuery plugin on the page: Error: Syntax error, unrecognized expression: [object Object][rel="7"]

Note: The plugin works fine when running jQuery 1.4.2, but running multiple jQuery instances isn't an option for this project.

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

Best Guess

So far I think I've managed to narrow it down to these two lines in his js file (jquery.dcdrilldown.1.2.js)

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

And as best I can tell breaks after calling

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

Because firebug doesn't make it to the breakpoints in findMaxIndex() method.

My HTML file looks like this

JS Call

$(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>

Any help you can offer will be greatly appreciated, thanks everyone.

like image 305
Miguet Schwab Avatar asked Sep 27 '12 20:09

Miguet Schwab


1 Answers

You need to look at what objUl is being set to. I bet before it used to resolve itself to a string when you concatenated to another string. Now it probably doesn't do that (hence the [object Object] part).

Look at what objUl is being set to and try to get maybe it's .attr('id') value instead.

Edit Change

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

to

var maxUl = $(objUl.attr('id')+'[rel="'+maxItems+'"]'); 
like image 88
jwendl Avatar answered Sep 30 '22 18:09

jwendl