I am trying to build a drag and drop control for the image type control in a plugin. Normally it provides for just a simple file selector.
I have it working just to the point of the Submit. I am having trouble to understand what the submit (getForSubmit) is looking for. I tried the file location and the actual jpeg blob data.
When submitting it does not accept the input and nothing is submitted of the form.
What is this getForSubmit looking for?
Runner.controls.MyPlugin= Runner.extend(Runner.controls.Control, {
.
.
.
getForSubmit: function () {
if (!this.appearOnPage()) {
return [];
}
return ['C:\\Users\\Myuser\\Desktop\\MyImage.jpg']; // the file location
or
return [file.data]; // the actual blob data
// this is the return used in the example; return [this.valueElem.clone().val(this.getValue())];
}
});
As a test I hard coded the selectors to see if the return "cloneArr" look the same in the normal and the plugin. Looks ok, though a lot of stuff in the control. Again, it works up to the point of the submit. Not sure what it is looking for. Any help would be appreciated.
getForSubmit: function() {
/**
* Clone html for iframe submit
* @return {array}
*/
// add real file elem
var radioClone;
var cloneArr = [];
// update
if (selector_mode == 3) {
radioClone = document.createElement('input');
$(radioClone).attr('type', 'hidden');
$(radioClone).attr('id', 'type_ChartImage_1_update');
$(radioClone).attr('name', 'type_ChartImage_1');
$(radioClone).val('file2');
cloneArr.push($(radioClone));
}
//keep
if (selector_mode == 1) {
radioClone = document.createElement('input');
$(radioClone).attr('type', 'hidden');
$(radioClone).attr('id', 'type_ChartImage_1_keep');
$(radioClone).attr('name', 'type_ChartImage_1');
$(radioClone).val('file0');
cloneArr.push($(radioClone));
}
//delete
if (selector_mode == 2) {
radioClone = document.createElement('input');
$(radioClone).attr('type', 'hidden');
$(radioClone).attr('id', 'type_ChartImage_1_delete');
$(radioClone).attr('name', 'type_ChartImage_1');
$(radioClone).val('file1');
cloneArr.push($(radioClone));
}
var realFile = this.valueElem;
var clone = this.valueElem.clone(true);
clone.insertAfter(realFile);
cloneArr.push(realFile);
this.valueElem = clone;
debugger;
return cloneArr;
}