javascript - multiple instances of valums file uploader -
i'm trying multiple instances of valum file uploader working on site. works great 1 instance anytime loop on initialization code, wanting multiple buttons don't see buttons. here's code:
<cfoutput query="gettopics"> <script> function createuploader(){ var uploader = new qq.fileuploader({ element: document.getelementbyid('file-uploader#reftopicid#'), action: 'components/projectbean.cfc', params: {method: 'upload', topicid: #reftopicid#, count: #evaluate("session.#reftopicabv#count")#, topicname: '#reftopicabv#' }, encoding: 'multipart' }); } // in app create uploader dom ready // don't wait window load window.onload = createuploader; </script> <div class="row" id="file-uploader#reftopicid#"> </div>
any idea how multiple instance? in advance!
you're creating javascript function inside of loop. in other words you're defining multiple times.
instead should move createuploader function outside of loop. , within loop, call multiple times each of topics.
something this:
<script> function createuploader(elementid, topicid, topiccount, topicname){ var uploader = new qq.fileuploader({ element: document.getelementbyid(elementid), action: 'components/projectbean.cfc', params: {method: 'upload', topicid: topicid, count: topiccount, topicname: topicname }, encoding: 'multipart' }); } </script> <cfoutput query="gettopics"> <script> createuploader('file-uploader#gettopics.reftopicid#', #gettopics.reftopicid#, #session[gettopics.reftopicabv & "count"]#, '#gettopics.reftopicabv#'); </script> <div class="row" id="file-uploader#gettopics.reftopicid#"> </div> </cfoutput>
nb: i'm assuming values come query gettopics
, i've prefixed them query name scope them properly. isn't essential, it's practice performance reasons (among other things).
Comments
Post a Comment