NicolasCARPi / jquery_jeditable

jQuery edit in place plugin. Extendable via plugin architecture. Plugins for plugin. Really.
https://jeditable.elabftw.net
MIT License
1.74k stars 458 forks source link

Pass extra parameters using submitData #249

Closed kkaiser1952 closed 2 years ago

kkaiser1952 commented 2 years ago

Hello Keith,

To pass extra parameters, use submitData. See "Complete example" on https://jeditable.elabftw.net/.

_Originally posted by @NicolasCARPi in https://github.com/NicolasCARPi/jquery_jeditable/issues/248#issuecomment-1128486987_

kkaiser1952 commented 2 years ago

Nicolas the above comment to my previous problem only solves my issue if I can pass a parameter to the submitData. I'm still something of a hack writing this code and try as I might and google for more help as I may I could not figure out how to pass a simple parameter to be used by the MySQL to get the data. The examples you have given are fantastic but my knowledge of extra syntax is not. Where/how is the parameter passed, its not in the submitData example near as I can tell.

kkaiser1952 commented 2 years ago

Even when i hard code a value into the submitdata i get errors. This is my current code, please help me with the syntax to make this work.

$(".editfacility").editable("save.php", {
            type       : "select",
            tootltip   : "Facility names, click to edit...",
            submit     : "OK",
            style      : "inherit",
            loadtype   : "GET",
            loadurl    : "getListOfFacilities.php",
            submitdata : {recordID : 95633},
                //recordID = $(this).attr("id").split(':').pop();
                //console.log("#108 recordID: "+recordID);
           // }
         }); 
NicolasCARPi commented 2 years ago

Hello Keith,

Taken directly from the example page:


var submitdata = {}
submitdata['recordID'] = '95633'

$(".editfacility").editable("save.php", {
            type       : "select",
            tootltip   : "Facility names, click to edit...",
            submit     : "OK",
            style      : "inherit",
            loadtype   : "GET",
            loadurl    : "getListOfFacilities.php",
            submitdata : submitdata,
}); 
kkaiser1952 commented 2 years ago

My code: var submitdata = {};

     submitdata['recordID'] = '95633';

     $(".editfacility").editable("save.php", {
        type       : "select",
        tootltip   : "Facility names, click to edit...",
        submit     : "OK",
        style      : "inherit",
        loadtype   : "GET",
        loadurl    : "getListOfFacilities.php",
        submitdata : submitdata,
     });  

The result: Uncaught TypeError: data is undefined and Uncaught SyntaxError: unexpected token '...'

both of the above from; [jquery.jeditable.js:50:201]

Even if/when this works the value of recordID must come from; submitdata['recordID'] = $(this).attr("id").split(':').pop();

Or

$(".editfacility").click(function(){ var recordID = $(this).attr("id").split(':').pop(); Or even if I says inside this click function. How do I get it out of the click function? submitdata['recordID'] = $(this).attr("id").split(':').pop(); });

On Jun 1, 2022, at 2:40 AM, Nicolas CARPi @.***> wrote:

Hello Keith,

Taken directly from the example page:

var submitdata = {} submitdata['recordID'] = '95633'

$(".editfacility").editable("save.php", { type : "select", tootltip : "Facility names, click to edit...", submit : "OK", style : "inherit", loadtype : "GET", loadurl : "getListOfFacilities.php", submitdata : submitdata, }); — Reply to this email directly, view it on GitHub https://github.com/NicolasCARPi/jquery_jeditable/issues/249#issuecomment-1143227421, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2FIHDMSWSLH5DMKEV75G3VM4HX5ANCNFSM5WZSZ7VA. You are receiving this because you authored the thread.

kkaiser1952 commented 2 years ago

This works. Notice that i have to use 'loaddata' pointing to submitdata. BUT i still need to pull that value with $(this).attr("id").split(':').pop(); AND thant does not work. How do i get that value into editfacility?

kkaiser1952 commented 2 years ago

This works up to but not including the save.php access. var submitdata = {}; $(".editfacility").click(function(){ var recordID = $(this).attr("id").split(':').pop(); submitdata['recordID'] = $(this).attr("id").split(":").pop(); console.log("@108 submitdata= object below "+recordID); console.log(submitdata); });

     $(".editfacility").editable("save.php", {
        type       : "select",
        tootltip   : "Facility names, click to edit...",
        submit     : "OK",
        style      : "inherit",
        loadtype   : "GET",
        loadurl    : "getListOfFacilities.php",
        loaddata   : submitdata,

     });