I'm in the process of developing a Chrome extension, with the intention of providing "paste" functionality from Excel into a form/table in our ERP system (Sage ERP X3 V7).
I've got everything working reasonably swell, but I've run into issues getting the default events that fire when you manually input text, to fire when putting it in programmatically.
I've used 'Visual Event' to see what events listeners are assigned to the inputs, and tried manually triggering them using the jQuery .trigger method.
I'm not sure if it's just a timing issue or what? Normally when you manually enter lines, you'll hit tab to move to the next field, and it'll take a bit to validate your data before moving on. It's that validation I need to trigger here.
This is the code snippet I'm using to try and trigger the focusin and focusout events -
function pasteLineData(lineData, data_s_article){
console.log($(".s-list-core[data-s-article='" + data_s_article + "'] tbody>tr:last").length);
var fieldData = lineData.split("\t");
var f=0;
$(".s-list-core[data-s-article='" + data_s_article + "'] tbody>tr:last").each(function (){
var $fields = $(this).find("input[readonly!='readonly']:not(.s-readonly):visible");
$fields.each(function(){
console.log($(this).attr("id"));
console.log(fieldData[f]);
$(this).trigger("focusin");
$(this).val(fieldData[f]);
$(this).trigger("focusout");
f++;
});
});
}
(the selectors in use are just there to grab the specific table and only the active fields, a some are display only)
Any suggestions on how I can get my extension to simulate the entry process?