I am using the uploader control to upload a file. But I want to call a custom javascription after the upload completed. Is there any way i can specify multiple Click actions for a Button?
Or Is there a way to invoke the Trigger methods from custom javascript?
define(["sitecore"], function (Sitecore) {
var UploadContacts = Sitecore.Definitions.App.extend({
initialized: function () {
},
uploadFile: function () {
this.FileUploader.upload();
// custom calls
}
});
return UploadContacts;
});
I have done the same as your looking for here. The way I have done this is to specify a function for the uploader control to call back to on the upload completing.
In the initialize of your page code do something like this.
initialize: function () {
this.on("upload-fileUploaded", this.FileUploaded, this);
},
Here is an example of my call back function, the modal contains a reference to the uploaded item within Sitecore.You can get the Sitecore item ID of the newly created item as below.
FileUploaded: function (model) {
this.filesUploaded.push(model.itemId);
this.upFiles.viewModel.refreshNumberFiles();
if (this.upFiles.viewModel.globalPercentage() === 100) {
this.ImportData();
}
}