CDD only triggers JS change code on first change

softforge

Member
I have a CDD watching a database join. I have added alert('test') as a JavaScript change event to the CDD. When I load the page, I see the CDD check the database join value and then I get the test alert. However when I change the database join, the CDD refreshes but I dont get the alert.

I have spend some time trying to debug this but I cant work it out. For some reason, the CDD change event gets removed from the element between the first and second change. I guess this is because it has it's own change events to handle but this is causing custom ones to be lost.

Any help on this will be much appreciated. :)
 
I have done some more work on this and I've realised that there is a (related I think) JavaScript error occurring after once you submitted the form for the first time. This actually stopped the CDD working at all after the form has been submitted. The JS error is the following:

Timestamp: 28/03/2013 15:14:49
Error: TypeError: Fabrik.blocks[this.form.form.id] is undefined
Source File: /plugins/fabrik_element/cascadingdropdown/cascadingdropdown.js
Line: 46

You can see this problem on the diabetes site I sent access details to (ages ago, I can resend if needed) on this page:

/staying-healthy/alcohol/tools-for-cutting-down-on-alcohol/my-alcohol-tracker

Thanks for any help you can give.
 
I don't seem to be able to find your site details. I typically delete pm's with login details in them after a month or so. Usually my browser will remember URL fragments, but in this case staying-healthy is not coming up with any previous links I've visited.

We're in the process of implementing a Fabrik based system on this new site which will let you store details of your sites, and we can refer to them directly from forum threads, but that isn't quite ready yet.

-- hugh
 
which element's have the js attached to them? I don't see any alert when the page loads for me
 
We removed the alerts as the site has gone live but I've managed to solve this by unlicking the copied elements form their parents.

However, I'm still getting this error described in my second post:

Timestamp: 17/04/2013 18:46:01
Error: TypeError: Fabrik.blocks[this.form.form.id] is undefined
Source File: https://www.help-diabetes.org.uk/plugins/fabrik_element/cascadingdropdown/cascadingdropdown.js
Line: 45

This is quite a big problem as only the first submission works. After saving one of the forms, the CDD doesn't work any more.

Any idea how to fix this?

Many thanks.
 
Hmmm, I can see what's happening, which is that when submitted, the form being submitted is being dropped out of the Fabrik.blocks object, but I can't see why.

I think it's something to do with the way you are redirecting from a PHP plugin on each of the forms. Your forms are rendered using content plugins in an article, which means they are submitted via AJAX, which means I don't think the $app->redirect() you are doing will actually do what you expect, as you can't redirect from an AJAX call without something on the client side JS doing it. Which is why we have options for that in the redirect plugin, along with JS which reloads the page if you select that option on the plugin.

However, that said, I'm still not sure why the form you submit is getting dropped from the Fabrik.blocks[].

May have to get rob to give me an assist on this one.

-- hugh
 
Thanks for looking into this. I found that $app->redirect() was causing a problem with the AJAX a while ago so the plugins were switched off. I have now deleted them just in case but the problems still occurs.

rob, it would be great if you could assist on this one. I have spent many hours trying to fix it but I'm at a loss... :confused:
 
ok it seems that we are destroying the form object after the ajax post, from the code it seems like it was deliberately done, but I can't remember why. I've commented it out in github for now, so if you update you should be able to submit the form more than once.
 
Wow. Looked at the commit, don't know how I spaced on those lines. I know I stepped through that code. I'm losing my mind.

But yeah, I'm willing to bet that'll fix this. Although as you say, I can't remember why we removed the form from blocks[] in the first place, so no doubt whatever we fixed with that will now break again, LOL!

The Fabrik Tango. Two steps forward, one step back. You put your left leg in, your put your right leg in, you do the Fabrik Tango and fall over.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top