Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not able to get pass the js piece to insert a link using the linkit button within CKEditor. The js script is able to perform search of nodes, but when I cliclk the "Insert Link", I get the following:
The following error shows in js inspector:
Comment | File | Size | Author |
---|---|---|---|
#7 | after_insertLink.jpg | 573.06 KB | mtaggart |
#7 | 2_errors.jpg | 66.92 KB | mtaggart |
#6 | linkit error.jpg | 69.52 KB | mtaggart |
#3 | error.jpg | 77.94 KB | gmclelland |
Comments
Comment #2
anonThis usually happens when there is a javascript error somewhere. It doesn't have to be linkit's fault.
Please check the browser console to see the error message.
Comment #3
gmclelland CreditAttribution: gmclelland commentedI just ran into this problem as well.
This happens when I'm editing a node and click the linkit button and start typing in linkit's search field. It does show the files in the drop down list, but when you select it and choose insert it takes you to a page that just displays json.
I'm using the latest linkit 3.x-dev with the Ckeditor module with the latest Ckeditor library and Scald-1.x-dev.
This doesn't happen on every node which is strange.
Hope that helps
Comment #4
gmclelland CreditAttribution: gmclelland commentedFor me, the only difference between content types is that the content type that has a paragraph field(https://www.drupal.org/project/paragraphs) added to it is the one that has the problem. The other content type works fine.
Comment #5
anonSo it seems to be a duplicate of #2551287: Linkit / Paragraph module issue
Comment #6
mtaggart CreditAttribution: mtaggart as a volunteer commentedI'm re-opening for further review. The PHP setting to increase max_input_vars did nothing. I'm attaching the js error when I get the json type response.
Also, I'm seeing the error in that an anonymous function is being called. It's probably trying to call for the "insertLink" function and not finding where to get the definition for the function.
Comment #7
mtaggart CreditAttribution: mtaggart as a volunteer commentedComment #8
anonThe images tells me almost nothing.
Tell me about your setup instead. For example, do you have the paragraph module installed and enabled for that content type this error occurs with?
What did you set max_input_vars to?
Comment #9
mtaggart CreditAttribution: mtaggart as a volunteer commentedmax_input_vars is set to 5000. I am NOT using the paragraph module. I'm also able to use the LinkIt icon up to a certain point. Here's the step by step:
> Create a new post
> Select the LinkIt icon, gets the first JS error == Uncaught TypeError: Cannot read property 'afterInit' of undefined
> Searched for a node, successfully able to retrieve the node searched for
> Click "Insert Link", gets the second JS error == Uncaught TypeError: Cannot read property 'insertLink' of undefined
> I get JSON response, see jsonResponse
Comment #10
justindodge CreditAttribution: justindodge commentedI'm experiencing similar symptoms - when clicking 'insert link' I'm taken to the raw json page. When clicking 'cancel', nothing happens at all.
In my case, there are no javascript errors - the problem appears to be that the linkit JS and CSS files are not making it into the page. I see that they are in the #attached portion of the form in linkit_dashboard_form(), but it looks like there is something odd about the way that form is rendered which is perhaps causing them to not make it into the page.
For me, I was able to implement a workaround in a custom hook that simply involves loading these missing files on hook_init - then everything is good for me. I'm not certain if this is a separate issue from the posts above or not.
Comment #11
anon@mtaggart: Any other modules that can affect this?
@justindodge: Thanks but that solution is not going to be in the module. I won't add linkit assets on all requests.
Comment #12
justindodge CreditAttribution: justindodge commented@anon My solution does not add the assets on all requests, it adds them on node/add/* and node/*/edit pages only.
Also, it is not at all intended to be introduced into the module's code base, but can potentially be used as a temporary workaround for those needing a quick solution to the issue and also as a demonstration that, at least in my case, the issue is actually caused by missing assets. So I'm not trying to offer a solution, but an insight into the problem.
Comment #13
anon@justindodge: Sorry, my bad. Didn't see the matcher_path part.
Comment #14
mtaggart CreditAttribution: mtaggart as a volunteer commented@anon I can't think of anything that could affect the module but I won't say 100% that's true. But I'm using the following CKEditor module:
CKEditor module version: 7.x-1.16+9-dev
CKEditor Library version: 4.4.7
Comment #15
anonjust as a test, try create a new content type, with only the field using the editor. If that doesnt work, try that with a default template.
Comment #16
mtaggart CreditAttribution: mtaggart as a volunteer commented@anon I did create a new content type, with no progress/difference. I'm not sure what you mean by default template though.
Comment #17
anonWhat I'm trying to say is that in order to find whats causing the issue, we need to find the failing component.
Default template could be any template in core, Bartik or Seven. If it works with one of them, its probably a theme issue in the custom theme you are using. If not, its something else.
This works on a clean install of drupal with just the required modules and setup, therefor its a combination of Linkit and something else.
We are now searching for the else part. Can it be the token module? Is that installed? Did you create a new content type with only 1 field that contains the editor? Can it be another custom editor plugin?
Comment #18
anonCan you test the patch in #2249097: CKeditor dialogue works on one node type, broken on another and see if that helps
Comment #19
gmclelland CreditAttribution: gmclelland commentedI tested the patch, but the patch didn't seem to work for me. I verified the file was patched correctly and that the browser was loading the patched js file. I didn't see any difference. When I clicked insert link, it showed a page with JSON. I tested this on a content type that has a paragraph field.
Comment #20
capogeannis CreditAttribution: capogeannis as a volunteer commentedIn the same boat. Using #10's workaround for now. Following this thread with keen interest.
Comment #21
capogeannis CreditAttribution: capogeannis as a volunteer commentedI actually had to rollback the #10 workaround is it causes the following js error on edit forms with link fields that do not have linkit enabled (for me, at least):
Uncaught TypeError: Cannot set property 'requiredFieldsValidation' of undefined
Comment #22
elektrorl CreditAttribution: elektrorl commentedIn my case, it seems, LinkIt does not support the class applied to the button "Insert Link". I rewrote classes to adapt my theme to Foundation. If you do the same for a framework like Bootstrap, you might get this 'json' error.
Comment #23
elektrorl CreditAttribution: elektrorl commentedlinkit.dashboard.js >> replace .linkit-insert with #edit-linkit-insert. This should work with all themes.
Comment #24
gmclelland CreditAttribution: gmclelland commentedThanks @elektrorl, but it didn't work for me. I'm using the stock seven admin theme with the Paragraphs module.
Comment #25
anonComment #26
gmclelland CreditAttribution: gmclelland commentedTry the patch in #2720373: Incompatibility between LinkIt with CKEditor and Scald. It fixed the problem for me.