How to open editor form in my own logic?

How to open editor form in my own logic?

merchantwarriormerchantwarrior Posts: 1Questions: 1Answers: 0

Hi there,

I used a customized button and would like to open editor form in the click event of the button. What I did was call editor.open() in the action property. However, I encountered a problem when I was trying to do this. The error says "Uncaught TypeError: Cannot read property 'focus' of undefined". Can you help me out?

Moreover, I wanna trigger my own function instead of the default one when I close the editor form. Could you give me any suggestions?

Any help will be appreciated.

The code I wrote was as following:

editor = new $.fn.dataTable.Editor( ..
buttons: [
{
extend: "create",
text: "New MID",
editor: editor,
action: function(e, dt, node, config){
editor.open(); // Error happened here
}
},
]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Rather than calling open(), call edit() (or create() / remove()). Otherwise Editor doesn't know what action to perform.

    The open() method is only useful if you use the options in the editing methods to cancel the default open action.

    Allan

This discussion has been closed.