A javascript "undefined error" in linkit.dashboard.js on line 153 is causing the Linkit to not work after the "Insert Link" is clicked. The result is the ajax response errors out and the page is taken to the response code.

line 153
attributes.push($(this).attr('name').substr(7));
Error: substr can't be called on undefined.

Looking the code, the loop on line 151 $('#linkit-modal .linkit-attributes .linkit-attribute').each(function() { is pulling in elements that don't have a "name" attribute. This errors out the Drupal.linkit.additionalAttributes function.

Adding a if () for a name attribute should fix the problem.

CommentFileSizeAuthor
#1 jsundefinederror-2158561-1.patch564 bytestravelertt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

travelertt’s picture

Priority: Normal » Major
Status: Active » Needs review
FileSize
564 bytes

Patch adds a if() checking for a "name" attribute on the loop item.

travelertt’s picture

I believe this is problem do to newer browsers being stricter js errors.

Was running Chrome Version 31.0.1650.63 and jquery 1.7

anon’s picture

What type of element don't have a name?

Don't all elements need a name? I mean why add it without a name, it can't be posted if it doesn't have a name.

travelertt’s picture

double entry

travelertt’s picture

Many elements don't have the name attribute. In this instance I believe it was finding a

. This patch checks for the existence of a filled name attribute, and returns false if the element if it doesn't. Otherwise the function fails later on when it tries to call an undefined attribute.
anon’s picture

"Many elements don't have the name attribute"
This is the real problem.

Linkit tries to pull elements out of a form.
All form elements can have a name attribute, and in fact, they should! What kind of input, select and so on doesn't have a name?
They are given names thru FAPI, if they don't, something is really messed up here.

anon’s picture

oh, I missed your "I believe it was finding a ".

Then I most know what kind of attributes do you have active?
Only the once that comes with Linkit core, or any own, or contrib attributes?

As Linkit core don't put "linkit-attribute" classes on any <a> tags.

travelertt’s picture

Sorry about that. I must have deleted the wrong duplicate post. It is finding a

element without a name attribute. I believe it was a vertical-tab
.
anon’s picture

Anyway, it doesn't make sense. The sciprt you havnig an error with is just using elements with the class "linkit-attribute".

If any other elements except the attribute field in the form have that class, something is really wrong, and it's not in control of Linkit.

anon’s picture

Status: Needs review » Closed (cannot reproduce)

Status: Closed (cannot reproduce) » Needs work

The last submitted patch, 1: jsundefinederror-2158561-1.patch, failed testing.

anon’s picture

Status: Needs work » Closed (cannot reproduce)

Closing again, the test bot change the status for some reason.