confusion about function parameters to editor.inline() function

confusion about function parameters to editor.inline() function

jettyappjettyapp Posts: 15Questions: 3Answers: 0

Description of problem: if you look at the editor's inline function page:
NONE of the examples sends parameter 2 or 3 as documented.
One of the examples sends a 'settings' object as parameter #2 which is documented to be "a single field name to edit"...

What the heck is going on here? The examples I have seen don't work according to this documentation either.
see: for an example.
What am I missing?

This question has accepted answers - jump to:


  • kthorngrenkthorngren Posts: 14,120Questions: 25Answers: 3,328
    Answer ✓

    The fieldName parameter is optional and is expected to be a string. The opts parameter is also option and is of form-options which looks like its essentially an object. I think the Datatables code does type checking and if, in this case, the type is a string it will process it a the fieldName parameter. Otherwise if its an object (form-options) it will process it as the opts parameter.

    I've seen this type of pattern in other places in Datatables.

    Does this answer your question?


  • jettyappjettyapp Posts: 15Questions: 3Answers: 0

    Thank you kthorngren, yes, maybe that's what is going on here. That does not jive well with TypeScript which is trying to protect us from getting parameters messed up, also it is really subtly documented. i.e. that the last to parameters are shown as optional. It would have been far better if the option could be either a value or null for no value.

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin
    Answer ✓


    Kevin is spot on as usual. The square brackets in our method documentation indicate an optional parameter, so in a more overload type methodology the method signatures would be:

    inline( nodes )
    inline( nodes, fieldName )
    inline( nodes, opts )
    inline( nodes, fieldName, opts )

    We used the square bracket notation assuming that developers would be familiar with it from jQuery's documentation, but we guess we've moved away from that now :).

    The overload structure might be clearer, I'll look into doing that - although it would take time since there is a lot of documentation :).

    If TypeScript is objecting to that, then we must have messed up our TypeScript definition for Editor and looking at the code, that is indeed the case - sorry! I've logged a bug for that and will get it sorted out.


  • jettyappjettyapp Posts: 15Questions: 3Answers: 0

    Thank you Allan!

Sign In or Register to comment.