Hey, I’m new to webix and I’m using webix jet too. I’m trying to write code for uploading file to server, well I’m not prepared the server completely yet, but this code not firing any http request, based on network activity on inspect element.
But strangely, onUploadComplete method got executed. can anyone help me please ?
here is my code
//
import {JetView} from "webix-jet";
export default class UploadView extends JetView{
config() {
return {
view : "layout", //optional line
responsive : true,
cols: [
{ gravity:1, template:""},
{
gravity : 2,
rows: [
{ gravity: 1, template: "" },
{ view:"template", icon:"mdi mdi-upload", template:"<i class='mdi mdi-upload'></i> Upload File", type:"header" }, // 1st row
{
minWidth : 300,
maxWidth : 500,
view : "form",
id : "formUpload",
elements:[
{ view:"text", label:"Song's title", labelPosition:"top", name:"title", id: "fileName",
on : {
onChange : (newv, oldv) => {
this.$$("upl1").define("formData", {
title : newv
});
this.$$("upl1").refresh();
webix.message("Value changed from: "+oldv+" to: "+newv);
},
onEnter : () => {
this.sendfile();
}
}
},
{
cols : [
{
view : "uploader",
upload : "//docs.webix.com/samples/server/upload",
id : "upl1",
css : "webix_primary",
value : "<i class='mdi mdi-plus-circle'></i> Add File",
//accept : "audio/*",
inputName : "file",
autosend : true,
multiple : false,
on : {
onBeforeFileAdd: (file) => {
const fileName = file.file.name;
const cleanName = fileName.split(".");
this.$$("fileName").show();
this.$$("fileName").setValue(cleanName[0]);
this.$$("upl1").define({
formData : {
title : cleanName[0]
},
value : "<i class='mdi mdi-plus-circle'></i> Change File"
});
this.$$("upl1").refresh();
return false;
},
onFileUpload : (file, resp) => {
if (resp){
webix.message(resp);
}
},
onFileUploadError : (file, error) => {
webix.message("Error : "+error.toString());
},
onUploadComplete : (resp) => {
const msg = resp ? resp.toString() : "";
webix.message("Done! "+msg);
}
}
},
{
view : "button",
label : "<i class='mdi mdi-cloud-upload'></i> Upload",
click : () => {
this.sendfile();
}
}
]
}
]
},
{gravity: 1, template: ""}
]
},
{ gravity:1, template:""}
]
};
}
init() {
this.$$("fileName").hide();
}
sendfile(){
const myfile = this.$$("upl1");
myfile.send(() => {
myfile.files.data.each((obj) => {
webix.message(JSON.stringify(obj));
});
});
console.log("sure you do something ?");
}
}