There is a potential problem with ajax page loads. If another module, say popups api, loads content via ajax, that content will have no drupal.settings.views_accordion object associated with it. As a result, the $.each statement at the begining of the javascript file will choke.
Can I suggest wrapping this entire statement in a conditional thus
<?php
...
if(Drupal.settings.views_accordion){
$.each(Drupal.settings.views_accordion, function(id) {
...
}
}
...
/?>
Comments
Comment #1
manuel garcia commentedHumm not sure I'm understanding the problem here nwe_44 .... can you give me a step by step scenario so I can replicate/debug this?
Comment #2
nwe_44 commentedI'm experiencing the issue when using views accordion in conjunction with the "popups api" module, but I suspect that any module attempting to make an ajax request and then run attach behaviours on it will choke if views accordion is invoked on the original page, but not the content of the ajax request.
A simplified step by step of my scenario.
1. Build a view using views accordion.
2. Install popups api
3. Add an "edit link" field for each node displayed in the views accordion using views
4. Add the relevant "popups" class to each edit link so that popups is invoked on that edit link
5. Click the edit link.
In this circumstance a popup will appear, but no javascript behaviours will be attached to it.
I think this is because the content of the popup has no object drupal.settings.views_accordion, because the edit form for that node will not have views accordion invoked on it.
Comment #3
manuel garcia commentedI have followed your steps on my local install nwe_44, and the popup window with the node edit link appears fine, and I was able to edit the node and save the changes without any trouble....
Not sure what the problem is. The content of the popup should not have views accordion invoked on it, since it isn't a views accordion display, it's a node edit form.
I'm I missing something here?
Comment #4
manuel garcia commentedI think i now know what you mean:
1. You are using a popup link to a views accordion page.
2. That views accordion view has popup links.
3. The popup links dont work within accordion displayed in the popup.
I have managed to duplicate the above scenario, and indeed it doesnt work. I tried making the changes you suggest to views-accordion.js, but that didn't fix the issue, at least on my install.
Not sure what's causing this, any pointers anyone?
Comment #5
manuel garcia commented[edit]OK, yup, you are right, no behaviours attached to it. I will make the changes to the js file asap and commit it. Thanks for the report and patience!
Comment #6
manuel garcia commentedComment #7
manuel garcia commentedOk, I've commited the suggested change for fixing this. http://drupal.org/cvs?commit=234590
Thanks.
Comment #8
nwe_44 commentedGreat stuff. Thanks!