Title: Callback Option &#8230; ?
Last modified: August 30, 2016

---

# Callback Option … ?

 *  Resolved [ben_del](https://wordpress.org/support/users/ben_del/)
 * (@ben_del)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/callback-option/)
 * Hi there! Great plugin.
 * I’d love to have the ability to enter an optional callback function (or function
   name) to be fired when the .get for each SVG is finished. Would be very handy.
 * Cheers,
 * Ben
 * [https://wordpress.org/plugins/svg-support/](https://wordpress.org/plugins/svg-support/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * (@benbodhi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/callback-option/#post-6872663)
 * Hi ben_del,
 * Thanks for your support 🙂
    That sounds like a pretty useful suggestion. Would
   you mind sharing your use case with me so I can better understand what you want
   to achieve with this functionality?
 * Cheers
    Ben
 *  Thread Starter [ben_del](https://wordpress.org/support/users/ben_del/)
 * (@ben_del)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/callback-option/#post-6872669)
 * In my case, I’m animating certain elements of the SVG code using JavaScript. 
   But since the SVG code is loaded after the page load has finished, my animation
   script is failing, as there is no code present to animate (yet) when it fires.
 * So, it would be useful if I could specify a callback function(s) that would be
   fired at the ‘complete’ event of the get request for the SVG code.
 * I could see two ways to do it:
 * 1) A ‘global’ function to call, which would receive each given SVG as an argument.
   This could be an option of the plugin. Just a simple text field that would store
   a function name, which would then be called, passing each returned SVG as it’s
   main argument each time it’s called. This would be useful if, say, I knew that
   ALL my animations were going to need to fire an “animateSVG” function.
 * 2) SVG-specific function names. This could perhaps be assigned PER SVG. Somehow
   at the point of insertion/selection of the SVG image in the WP editor, a function
   name could be supplied by the user. This would then be stored as a data-callback-
   XXX attribute on the rendered SVG root node. Then the SVG Support script would
   search the DOM at the onComplete for elements that had a data-callback- prefix
   and fire their corresponding functions, again, passing the SVG element as an 
   argument to the specified function.
 * Those are just how I saw it happening. I’m sure there are many ways you could
   do it.
 * Thanks for the reply and for considering the feature addition.
 * best,
 * Ben
 *  Plugin Author [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * (@benbodhi)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/callback-option/#post-6872718)
 * Well that certainly sounds pretty helpful.
    I won’t get a chance to work on this
   for a while unfortunately, but will keep it in mind. Cheers
 *  Plugin Author [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * (@benbodhi)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/callback-option/#post-6872947)
 * Hey, I’m working on a few things for the next update and had a play with this
   idea… but I’m no JS expert and keep having trouble figuring out the best way 
   to do this…
    I wonder if you have any time to write in your own code how you 
   personally would use it? I would appreciate any help you can offer!
 *  Plugin Author [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * (@benbodhi)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/callback-option/#post-6872948)
 * I have added a new class with +index on the end, so each SVG rendered has a unique
   class for targeting… Not sure if this will help you, let me know your thoughts.
   
   The new JS file is in the dev version in trunk if you would like to test it.
 *  Plugin Author [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * (@benbodhi)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/callback-option/#post-8695956)
 * I have released these features live now, so will mark as resolved

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Callback Option … ?’ is closed to new replies.

 * ![](https://ps.w.org/svg-support/assets/icon.svg?rev=1417738)
 * [SVG Support](https://wordpress.org/plugins/svg-support/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/svg-support/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/svg-support/)
 * [Active Topics](https://wordpress.org/support/plugin/svg-support/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/svg-support/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/svg-support/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Benbodhi](https://wordpress.org/support/users/benbodhi/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/callback-option/#post-8695956)
 * Status: resolved