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

How to submit on mouse out #200

Closed dhruti3011 closed 5 years ago

dhruti3011 commented 5 years ago

I have jeditable datatable. I do not want the data to be saved onblur. What my implementation is that I have a "Save" button(outside of my table) which takes the values and then saves the values in the database. I do not want the "OK" button, hence I have the code "submit": "" What is happening is that I have to either press enter or click outside of my table to retain the values. What I require is that when I click "Save" button, onblur should be called so that the values are retained(or some other mechanism to retain the data on click of the button), which is not happening. salesDataTbl.$(edit).editable(theCallback, { tooltip: 'Click to edit and press enter', "callback": function (sValue, y) {

}, "submit": "", "onblur": 'submit', });

NicolasCARPi commented 5 years ago

Hello,

Why don't you use blur() on your table when the external save button is clicked?

dhruti3011 commented 5 years ago

Hello, I did try, but in vain. Is there another way? Regards, Dhruti

On Wed 24 Apr, 2019, 7:35 PM Nicolas CARPi, notifications@github.com wrote:

Hello,

Why don't you use blur() https://api.jquery.com/blur/ on your table when the external save button is clicked?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NicolasCARPi/jquery_jeditable/issues/200#issuecomment-486250026, or mute the thread https://github.com/notifications/unsubscribe-auth/AL5C57QKJ4SIZNHLLK4GRU3PSBSMJANCNFSM4HIEE4OA .

NicolasCARPi commented 5 years ago

It would help greatly if you could provide an example of your code running. I created a template to help with the process: https://codepen.io/pen?template=pBxBXm

dhruti3011 commented 5 years ago

Hello Nicolas,

Thank you for your quick response. I've saved the code: https://codepen.io/anon/pen/rbqEzJ It works in my local. Except that the rows are got from the database. Please let me know if you need any other details.

On Wed, Apr 24, 2019 at 8:11 PM Nicolas CARPi notifications@github.com wrote:

It would help greatly if you could provide an example of your code running. I created a template to help with the process: https://codepen.io/pen?template=pBxBXm

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NicolasCARPi/jquery_jeditable/issues/200#issuecomment-486271089, or mute the thread https://github.com/notifications/unsubscribe-auth/AL5C57XYLZRQ4BRHFZ5WPMTPSBWQDANCNFSM4HIEE4OA .

NicolasCARPi commented 5 years ago

You forgot to add jquery-datatable (in Settings -> javascript) in your example.

I do not see your Save button. Also note that onblur can be a function (see doc):

onblur: function() { return false }
// or
onblur: 'cancel'

Is this what you want?

dhruti3011 commented 5 years ago

Hi, The below code is not working.

onblur: function() { return false }// or onblur: 'cancel'

What I'm trying to do is, have onblur: submit.

And then when I click on save, ideally the onblur of datatable td method should be called first(as the focus is on the button now).

However, what is happening is it is calling the submit button, and at this point the new edited value is not reflected because the blur is not called.

On Wed, Apr 24, 2019 at 9:23 PM Nicolas CARPi notifications@github.com wrote:

You forgot to add jquery-datatable (in Settings -> javascript) in your example.

I do not see your Save button. Also note that onblur can be a function (see doc https://jeditable.elabftw.net/api/#jquery-jeditable):

onblur: function() { return false }// or onblur: 'cancel'

Is this what you want?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NicolasCARPi/jquery_jeditable/issues/200#issuecomment-486302169, or mute the thread https://github.com/notifications/unsubscribe-auth/AL5C57Q3PATKYAV5MJX4TADPSB7ARANCNFSM4HIEE4OA .

NicolasCARPi commented 5 years ago

Did you try with "onsubmit"? It is called before submit.

dhruti3011 commented 5 years ago

Hello ,

I found a work around for this. Thank you very much for your prompt support! :)

Regards, Dhruti

On Wed, Apr 24, 2019 at 9:55 PM Dhruti Shah dhruti3011@gmail.com wrote:

Hi, The below code is not working.

onblur: function() { return false }// or onblur: 'cancel'

What I'm trying to do is, have onblur: submit.

And then when I click on save, ideally the onblur of datatable td method should be called first(as the focus is on the button now).

However, what is happening is it is calling the submit button, and at this point the new edited value is not reflected because the blur is not called.

On Wed, Apr 24, 2019 at 9:23 PM Nicolas CARPi notifications@github.com wrote:

You forgot to add jquery-datatable (in Settings -> javascript) in your example.

I do not see your Save button. Also note that onblur can be a function (see doc https://jeditable.elabftw.net/api/#jquery-jeditable):

onblur: function() { return false }// or onblur: 'cancel'

Is this what you want?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NicolasCARPi/jquery_jeditable/issues/200#issuecomment-486302169, or mute the thread https://github.com/notifications/unsubscribe-auth/AL5C57Q3PATKYAV5MJX4TADPSB7ARANCNFSM4HIEE4OA .