Using javascript call after selecting a file with $al->image() (in block edit mode)

So, if I use this for selecting an image with the file manager:
$al = Loader::helper('concrete/asset_library');
echo $al->image('my_image_fID', 'my_image_fID', 'Choose Image', $my_image);

How can I trigger something in javascript after the user has chosen a file?
I just want to check or uncheck a checkbox in this case, though there's other scenarios I'm thinking about.

I've looked through the file "concrete/helpers/concrete/asset_library.php" but can't figure out what to do.

Any help appreciated, thanks!

View Replies:
ScottC replied on at Permalink Reply
there's two window functions you can potentially override:



Some of this stuff gets overridden with a load of the file manager in the modal so you need to make sure you rebind it after the file manager is closed..

It's a bit hairy but it can be done :)

yoschi replied on at Permalink Reply
Thanks for the answer :) that gives me a starting point.
I'm new to overriding functions in js but I'm eager to try it out so I've done this
var proxied = window.ccm_alSelectFile;
window.ccm_alSelectFile = function(args){
   //Performing checks
   console.log("File Chosen");

Ok, this worked! Awesome!
I have multiple "$al->image", how do I know which one has been selected from within my redefined function?
"args" only gives me the file number (I think it's the variable fID after looking at concrete's filemanager.js)