Question

I wrote a single button file upload using a hidden iframe and javascript to submit the form. I'm trying to get backbone to listen for when it is successful so I can create a new div for the image to be inserted onto the page but I am fairly new to how to listen for events. My approach is very primitive so feedback would be great--

When a file is submitted PHP will upload to the database and when complete will spit "Success" to the iframe.

Backbone, when Upload is hit, will check through Jquery at a certain time interval to find Success or Failed in the hidden iframe and then create a new Ad for the view once it does see the text in html.

This seems like a very bad way to handle it but I can't find an elegant solution.

Was it helpful?

Solution

Why would you need Backbone to listen for it? Normally you should have 'success' callback, following your upload request, to do all the associated work. If you, for what ever reason, have to use Backbone facilities, just issue custom event model.trigger('uploadDone')), and get a listener somewhere model.on('uploadDone', function(){})

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top