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

For a JSON return how do I pass a parameter to the php via loadurl? #248

Closed kkaiser1952 closed 2 years ago

kkaiser1952 commented 2 years ago

Description

Below is my code, how do I pass a recordID to be used by the getListOfFacility.php program?

var load_url = "getListOfFacilities.php";
         $(".editfacility").editable("", {              // Facility
             type    : "select",
             loadurl : load_url,
             placeholder: "",
                onblur: 'submit',
                submit:"OK",
             callback: function() {refresh();}, 
             tooltip : "Facility Click to edit...",
             style   : "inherit",
         });

I've tried ; getListOfFacility.php?recordID=95633 but that doesn't seem to do it I get no return.

How to reproduce

It helps a lot if you can create a working example from this template: https://codepen.io/pen?template=pBxBXm

Expected result

Actual result

Environment

jQuery version: 3.5.1 Browser: Any OS: Any

NicolasCARPi commented 2 years ago

Hello Keith,

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

kkaiser1952 commented 2 years ago

Thanks for getting back to me Nicolas but after about 90 minutes of trying to figure this out I'm not making any headway. My new code looks like this;

var submitdata = { 
             $(document).on("click", ".c33 td", function(e) {
                 var data = $(this).attr('id');
                 alert(data);
             }); 
         };
         var load_url = "getListOfFacilities.php";
         // with JSON feed
         $(".editfacility").editable("save.php", {              // Facility
             type    : "select",
             loadurl : load_url,
             placeholder: "",
                onblur: 'submit',
                submit:"OK",
             callback: function() {refresh();}, 
             tooltip : "Facility Click to edit...",
             style   : "inherit",
         });

I'm not getting the data from the clicked cell and I still don't see how it gets attached to the php program. The error from the above is "Uncaught SyntaxError: missing { before function body" Where am I going wrong? As usual I'm sure I'm making it more difficult than it should be.