rvera / image-picker

Image Picker is a simple jQuery plugin that transforms a select element into a more user friendly graphical interface.
http://rvera.github.com/image-picker
Other
907 stars 216 forks source link

Multiple functions on select. #116

Closed Powers-RC closed 6 years ago

Powers-RC commented 6 years ago

I am wondering if anyone has or knows how to call on several functions when an image is selected? I am considering just chaining the functions together by calling them inside the select: function() but I am against doing this. Also wondering if anyone has tried chaining multiple .imagepicker() functions together and how that resulted? I am getting ready to try all this so I will update this if I find a solution. Just wondering if someone has accomplished this already.

Powers-RC commented 6 years ago

I am reopening this issue because I am having trouble running multiple functions on select still. It seems that every time I select an option only one of the functions runs. Any suggestions on how to accomplish this?

rvera commented 6 years ago

Hi @Powers-RC, the interface only defines one callback, if you need to call multiple functions you would need to call them all inside that one callback. ie,

select: function() {
  methodA();
  methodB();
}

If this list is dynamic you would need to store them somewhere (like a map or array) and the iterate over this list to call them one by one.

Powers-RC commented 6 years ago

Thank you, this is what I needed to know.