(12-15-2018, 10:00 AM)skunkbad Wrote: Show your event handler. Is it just a click event?
Hey Brian.
Code:
$('#btnSubmitSurvey').button().click(function () {
if (iCertified==0)
{
alert("you must certify this survey");
return;
}
iCount=0;
iPercent=0;
iTotal=0;
for (iCount=0;iCount<6;iCount++)
{
iPercent=$('#tblAppendGridSurvey').appendGrid('getCtrlValue', 'Perc_time',iCount);
iPercent=parseInt(iPercent);
iTotal=iPercent+iTotal;
}
if (iTotal>100)
{
alert("Tasks are be greater than 100%");
return;
}
iCount=0;
iPercent=0;
iTotal=0;
for (iCount=0;iCount<6;iCount++)
{
iPercent=$('#tblAppendGridBCSurvey2').appendGrid('getCtrlValue', 'Perc_time2',iCount);
iPercent=parseInt(iPercent);
iTotal=iPercent+iTotal;
}
if (iTotal>100)
{
alert("Bus Comps are greater than 100%");
return;
}
data=new Array();
dataStructure=new Array();
data=$('#tblAppendGridSurvey').appendGrid('getAllValue', true); //get all the values of the grid
dataStructure.push(data);
data=$('#tblAppendGridBCSurvey2').appendGrid('getAllValue', true); //get all the values of the grid
dataStructure.push(data);
var year = document.getElementById('year').value;
dataStructure.push(year); //the year of this survey
//popup a message that data is being sent
// alert("your surveys are being sent to our server.");
chrome.extension.sendMessage({task:"log_results_survey", values: dataStructure}, function(response) {
//get results and send them
alert(response.task);
logged_in_user = response;
});
});
I think that this is what you mean. BTW, I also have this
Code:
//this stops the dblclick error
$("*").dblclick(function(event){
event.stopPropagation();
});
So the click sends a a "log_results_survey" message, which get heard by the Listener in the background task. The background task runs this:
Code:
if (request.task =="log_results_survey"){
send_to_logger_survey(request, sender, sendResponse);
};
The send_to_logger_survey() appears in my first post. One strange thing though that I just noticed. The response back to the initial popup task comes directly from the callback from the xhr, rather than being sent back from the on-message callback.
proof that an old dog can learn new tricks