table.editor() results in 'undefined'
table.editor() results in 'undefined'
Hi,
I am using a local inline editor with submit on blur which works just fine.
Now, I also want to submit just edited values when the submit button of the whole form is clicked. However, when the submit button is directly clicked, the submit on blur does not take effect.
Therefore, I call a JavaScript function before the actual submit action. In the JavaScript function I manually trigger editor.submit()
. This also works fine as you can see in this example.
However, when I use the same submit()
JavaScript function in my code, the editor
variable is always undefined
.
Any idea what could cause this issue?
Can this be narrowed down to some specific calls which I could post here? I do not want to post the whole JavaScript code here.
This question has an accepted answers - jump to answer
Answers
That would suggest it hasn't been declared. Or declared outside the scope of the area you're calling it in. WIthout seeing the code, or a link to the page, it's hard to say.
Colin
Hi Colin,
I tried to create a minimal example from my code to show the described behavior, see here.
Clicking the submit button results in error "editor is undefined".
Note that commenting out the
scroller
andscrollY
property seems to fix the error but I need to use the scroller extension.Thanks for your help.
Thanks for the test case, but it's not loading for me. Please could you take a look and ensure it replicates the issue reported.
Colin
Interesting. For me the linked test case works as expected. No matter which browser, even on different machines. Perhaps you need to clear your browser cache?
Its also not running for me I'm afraid (Firefox Linux), but is it this like that is causing your problems:
?
If so, try adding:
into your DataTables initialisation object. The
editor()
method isn't always able to pick up the Editor instance defined for a table and this change should address that.Allan
Hi Allan,
thanks, it seems that this solved it.
I never stumbled upon this
editor
property. Is it described somewhere?And I am still wondering why the example does not work for both of you. I have tried it on different machines, different browsers, mobile, it always works.
No idea why it isn't working I'm afraid!
The
editor
property actually isn't document - it's really a fallback. Indeed I wouldn't really encorage use ofeditor()
since it is quite possible to have multiple Editor instances for a single DataTable. Normally I would suggest assigning the instance to a variable and then using that variable whenever you need to access the instance.Allan