How to implement custom editor submit ,not editor.submit()

How to implement custom editor submit ,not editor.submit()

pig800509pig800509 Posts: 12Questions: 2Answers: 0
edited January 2018 in DataTables

DataTable Editor,
As title said,
How to implement onsubmit , or click submit button event?

I am using AWS SDK (DynamoDB, API GateWay, Cognito)
I know It's better way that use ajax in editor,
but I don't know how to send ajax request by using those AWS SDK
can you give me a example?
thanks

Answers

  • pig800509pig800509 Posts: 12Questions: 2Answers: 0

    I found a way!!

    editor.on( 'preSubmit', function ( e, d ) {
    //do somthing
    } );
    but I still want to know How use ajax send request to get aws dynamodb data and upload image to S3 bucket

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    If you want to override Editor's default Ajax submission and send your own, you are best to use ajax as a function. Then you can manipulate the data and send it wherever you need.

    Allan

  • pig800509pig800509 Posts: 12Questions: 2Answers: 0
    edited January 2018

    @allan
    I am stuck in 'asuccess', after asuccess was called, table won't update, how to implement custom success callback?

    ajax: async function ( amethod, url, data, asuccess, aerror ) {
    let meth,pat;

          try {
    
            switch(data.action){
              case "edit":
                meth = 'PUT';
                pat = `/notes/${Object.keys(data.data)[0]}`;
                break;
              case "remove":
                meth = 'DELETE';
                pat = `/notes/${Object.keys(data.data)[0]}`;
                break;
              default :
                meth = 'POST';
                pat = "/notes";
              break;
            }
    
            var postdata = data.data[Object.keys(data.data)[0]];
            ["error", "fieldErrors"].forEach(e => delete postdata[e]);
    
            await invokeApig({
              path: pat,
              method: meth,
              body: postdata
            });
    
            console.log(postdata);
            asuccess({postdata});
          } catch (e) {
            alert(e);
            aerror(e);
          }
    
        }
    
  • pig800509pig800509 Posts: 12Questions: 2Answers: 0
    edited January 2018

    @allan or any way to get data(by using $ajax) from AWS DynamoDB with cognito ?

    I am using serverless stack and github

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin

    Can you just use $.ajax() with a URL pointing to your AWS DB? Maybe I'm missing something there.

    Allan

This discussion has been closed.