Welcome Guest, Not a member yet? Register   Sign In
function being called twice
#4

(This post was last modified: 12-15-2018, 11:14 AM by richb201.)

(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
Reply


Messages In This Thread
function being called twice - by richb201 - 12-14-2018, 12:58 AM
RE: function being called twice - by richb201 - 12-14-2018, 07:34 PM
RE: function being called twice - by skunkbad - 12-15-2018, 10:00 AM
RE: function being called twice - by richb201 - 12-15-2018, 11:14 AM
RE: function being called twice - by dave friend - 12-15-2018, 11:42 AM
RE: function being called twice - by richb201 - 12-15-2018, 11:48 AM
RE: function being called twice - by dave friend - 12-15-2018, 01:40 PM
RE: function being called twice - by richb201 - 12-15-2018, 10:36 PM
RE: function being called twice - by richb201 - 12-17-2018, 06:58 AM
RE: function being called twice - by richb201 - 12-17-2018, 02:56 PM
RE: function being called twice - by Zigi84 - 01-06-2019, 06:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB