Multiple file manager triggers on the same page, or, why is ccm_chooseAsset() a global?

Permalink
Hi, I'm having trouble figuring out something regarding the file manager.

In some implementations, there is a callback function called ccm_chooseAsset() (e.g., in the content block).

In others (e.g., the one in helpers/concrete/asset_library), there isn't.

Actually, ccm_chooseAsset() isn't a "callback," it's defined as a global.

Looking at lines 752-787 of ccm.filemanager.js, it would seem that these things are true:

1. When a file is chosen, if ccm_chooseAsset does not exist, ccm_triggerSelectFile is called, which updates the selector interface created by the asset_library helper.

2. When a file is chosen, if ccm_chooseAsset DOES exist, it is called, and ccm_triggerSelectFile IS NOT called.

3. ccm_triggerSelectFile includes an id parameter to identify different instances of a file selector, but ccm_chooseAsset does not.

This seems to mean that:

1. A file selector that uses ccm_triggerSelectFile CANNOT be on the same page as one that uses ccm_chooseAsset, because the latter will prevent the former from being updated.

2. There can never be more than one file selector on a page that uses ccm_chooseAsset, because it is defined as a global without an index/id. Thus the wonky switch/case statement in ccm_chooseAsset in the content block.

Am I crazy? I want both a "choose image" selector and a content editor on the same page. I feel like that should be possible.

Thanks!
Dan M.

dmenssen
 
tbcrowe replied on at Permalink Reply
tbcrowe
I agree that ccm_chooseAsset is a poor design. You can have multiple file selectors on a page, however. The trick is to recognize that ccm_chooseAsset is a variable and to simply point it at the right function value at the appropriate time.