I have a Views grid page with a few node fields, one of which I'd like to open the node in a colorbox modal. When the page & view renders this error appears in the console.
Uncaught TypeError: Cannot call method 'replace' of undefined
Occurs in ajax.js @ line 132
I am using jQuery Update and have tried versions 1.5, 1.7 and 1.8.
Any suggestions?
This seems to be something related to the view or Views. If I create a colorbox-node link anywhere else in Drupal the modal works without error. Also, if i create a colorbox-node link in the views header or footer the modal works without error.
Comments
Comment #1
drupalshrek commentedI had exactly the same error: the problem seems that I had put 'colorbox-node' class on the field rather than the link. i.e. in views I had put the colorbox-node class on:
Style Settings --> Customize field HTML --> Create a CSS class --> CSS class
It should rather go on:
Rewrite Results --> Output this field as a link --> Link class
Or, to put it another way, I had generated:
rather than:
Anyway, having the colorbox-node class on the
<a> tagseems to have got rid of the above error, and seems to match more correctly the examples.I have not got the thing working yet, so take my advice with a large pinch of salt, but at least I now have a blank window which opens and then shrinks into a white dot, which is progress.
I suppose the js for colorbox_node could detect whether the class is found on the
<a> tag to avoid this.Comment #2
iLLin commentedThe reason the a tag is not targeted is it allows the developer to use an
<area>or any other container they want to use. So as far as "avoiding this" What are we avoiding? User error?Comment #3
Andre-Bunless you can prove that the changed selector a.colorbox-node and the other involved selectors (see latest patches too) will not have impact in performance and you provide a patch I'll close this as works as designed.
Comment #4
vbard commentedI think I have the same issue. I have a views grid with links. A link looks like this
http://188.226.132.156/gallery/chyorno-belye-sharzhi/14
And I have this error in my console "Uncaught TypeError: Cannot call method 'replace' of undefined"
Furthermore, only first link works as designed, showing a node in a colorbox window. All other links to other nodes opens a node as usual, without colorbox.
I don't know whethere this error in a topic subj is related to my described above, somebody please tell me if it is. Thanx.
Comment #5
drupalshrek commentedIt really would be good if you could make sure that colorbox-node is on the a tag before processing.
It is far too easy for a user to put the colorbox-node in the wrong place, and the big problem is that this can mean not only that colorbox does not do its thing, but that all the javascript on the site breaks and all sorts of horrible things happen with the site.
My javascript is not good enough to say the exact fix, but I think it should only be a question of testing that the tag is an a tag before assuming that there is a url to use.
It really is a nightmare to debug for all the users who get this problem, and it is extremely easy to accidentally get the css in the wrong place (you will see in the image that it looks perfectly reasonable), and yet it should in theory be easy to check that the url obtained really is from the a tag.
Comment #6
iLLin commentedI will put in a solution that checks to see if there is a URL present on the element that is being referenced. But then I will get questions... this module doesn't work with views.... at least this way stuff blows up. So maybe I won't, hmmm.
Comment #7
drupalshrek commentedYou'll save a lot of users a lot of pain if you do. At least something like this maybe: