Chaos Tools can be fantastic to work with on the php side. And has helped pick up alot of the heavy lifting of javascript. Which is great, but interacting with ctools on the JS side can be a bit of a pain. It's possible im just take the wrong approach and there already be better approaches to these types of problems. Having said that I feel it would be useful if chaos tools provided custom javascript events to some of the plugins.
For example events like modalBeforeOpen, modalOpen, modalClose, ajaxResponderComplete, etc, etc.
This came to thought after working on a project that leverages the ajax responder plugin. Which worked well, but I found no way in javascript to attach to the responder and find out if it has completed running all of its commands. Something like this would simplify writing javascript that has to execute after or before these interactions take place.
Comment | File | Size | Author |
---|---|---|---|
#16 | ctools-modal-display-attach-behaviors-1018724-2.patch | 491 bytes | earthday47 |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThere is an event that fires when the modal closes now, but that's the only one I've added. It seems reasonable to add more as we identify good ones.
I probably won't add any events to the ajax responder, since that code is in core in 7 and I'd rather not have code in 6 that I can't also put in 7, it's already hard enough. I can do stuff like that with the modal, though.
Comment #2
cangeceiro CreditAttribution: cangeceiro commentedIn the particular use case that I am working with, I want to be able to listen for an event that lets me know that the modal has finished loading so that I can attach to the event, and does some logic when the modal is done rendering, but currently have no way to listen for that event.
I implemented the above to accomplish this. However I'm open to input if you think there is a better place to put this trigger to get it committed. Or if there is just a better way to go about this.
Comment #3
cangeceiro CreditAttribution: cangeceiro commentedI am running into another situation where this would be really helpful to have in the js api of modals. attached is a patch that triggers CtoolsAttachBehaviors once the modal is done rendering and has focus. Patch is against 7.x
Comment #4
rjbrown99 CreditAttribution: rjbrown99 commentedBeen playing around with this. I'm using 6.x but the concept is the same for both. I am using this with a ctools wizard multi-step modal form. What I want is an event that fires after the new modal form is completely done loading. I can't use click handlers on the previous step's submit function because that won't account for form validation failures. IE, if you are on step #1 of my multi-step form, and validation fails, I do not want to run any events. I want the event to only run when we successfully passed validate+submit on step 1 and we're on to step 2 with a fully loaded new form.
Patch #2 sort of works, in that it will run an event on the second form. The problem is it fires multiple times as content is being loaded into the modal. In my case I have it loading a carousel of images and it's firing on each image that is loaded. This is undesirable as I want only one event at the tail end of loading.
Patch #3 is not fired at all after new content is loaded to the modal. It's only fired when the first modal form pops up.
I'm off to search for the right place to fire this event - one time, after the modal is done loading.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commented#4: For your comment about #2, I'm not sure CTools has any knowledge of 'tail end of loading' -- if it calls modal_display it can't tell the difference between an update and a fresh load. You'll have to have some kind of marker to figure that out on your own, I think.
Why does #3 not include #2?
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedComment #7
cangeceiro CreditAttribution: cangeceiro commented3 was basically a different approach that I tried on a different project. I can't say I have settled on the best way to approach this. if you have time during drupalcon I would be happy to meet up and discuss more in depth, also wouldn't mind chatting in person in regards to the field able panel panes module.
Comment #8
rjbrown99 CreditAttribution: rjbrown99 commentedI just settled on #2 for now as-is and worked my own JS around it. For right now it works for my need for an event.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedSure, I'd love to.
Comment #10
cangeceiro CreditAttribution: cangeceiro commentedwhats the best way to track you down? I had no idea this place would be as packed as it is.
Comment #11
rjbrown99 CreditAttribution: rjbrown99 commented#10 try Twitter - I have seen him pop on there a few times recently. @merlinofchaos
Comment #12
merlinofchaos CreditAttribution: merlinofchaos commentedI remember meeting you but I don't remember what we actually discussed, or if we managed to discuss what you wanted. Much of Drupalcon is a blur to me. :(
Comment #13
cangeceiro CreditAttribution: cangeceiro commentedIts all good, i was still in precaffiene daze myself. I was just wanting to clear up the possibility of getting this patch to add CtoolsDetachBehaviors committed. and if the there was anything else i could do to get the patch up to snuff to do so.
Comment #14
merlinofchaos CreditAttribution: merlinofchaos commentedI think we just need to resolve the differences; I marked it needs work because there are 2 approaches and I'm having trouble telling which one of them was working for other people. When someone says "This doesn't work for me" but it's not clear why that tends to slow things down.
Comment #15
earthday47Very interested in this.
Here's a patch that implements comment #2, applied against 7.x-1.x.
Comment #16
earthday47Here's the same patch applied from 7.x-1.4.
Comment #17
temkin CreditAttribution: temkin as a volunteer commentedComment #19
temkin CreditAttribution: temkin as a volunteer commentedLooks good!
Comment #20
geek-merlinComment #21
MustangGB CreditAttribution: MustangGB commentedWhy is this a regression risk at all?
Comment #22
DamienMcKennaComment #23
joelpittetComment #24
rivimey@axel.rutz please explain the regression risk -- or we have no way to either evaluate the risk, explain it, or mitigate it.
Comment #25
geek-merlin> please explain the regression risk
i added that tag "low (or no) regression risk" a year ago to sort issues for a release. you can ignore or remove this now.
Comment #26
MustangGB CreditAttribution: MustangGB commentedComment #27
joelpittetComment #28
joelpittetThanks I've committed this to the dev branch and will be in the next release (today). Thanks for your patience and hard work on this everybody!