Script error when clicking the save button on a new record

Script error when clicking the save button on a new record

shankslouisshankslouis Posts: 2Questions: 1Answers: 0

Problem:
I get an error
"Uncaught TypeError: Cannot read property 'first_name' of undefined"
when I attempt to 'save' a new row\entry. If I remove all of the fields: [{}] I have defined in my $.fn.dataTable.Editor I don't see the script error and the ajax post does fire.

Repro Steps:
It is the same error you see if you
1) open https://editor.datatables.net/examples/simple/simple.html
2) Open developer tools in your browser
3) open console in the developer tools
4) On the webpage click 'New' and enter details
5) Click create.

Error:
You will see the following error in the console

Uncaught TypeError: Cannot read property 'first_name' of undefined
    at https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js:19:488
    at f.(anonymous function).(anonymous function) [as valFromData] (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:79:44)
    at f.(anonymous function).<anonymous> (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:459:134)
    at Function.each (https://code.jquery.com/jquery-1.12.4.js:376:19)
    at Object.<anonymous> (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:459:19)
    at Function.each (https://code.jquery.com/jquery-1.12.4.js:376:19)
    at f._submit (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:457:139)
    at m (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:329:231)
    at f.submit (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:333:3)
    at f.action (https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js:607:34)

I get the same error, only when using the New\create button. Edit\Delete work and I see the ajax post as expected.

Question:
Is there something you must add to get the ajax post request to fire on a New\Create that isn't included in the sample?

If we could get https://editor.datatables.net/examples/simple/simple.html to work without the script error I'm sure I could fix my code.

Thanks everyone.

Answers

  • shankslouisshankslouis Posts: 2Questions: 1Answers: 0

    [Update]

    The issue with the "New" button not generating a Ajax post and throwing the above error has been resolved when I purchased a license. It seems to be a limitation in the trial version. Without changing my code I dropped the licensed .js files over my trial version and reloaded the page and everything is now working.

    I have to say this is really a nice library, and so far seems to be worth the money. I only wish the samples had some sort of disclaimer that this, or that will not work in the trail version.

  • allanallan Posts: 62,377Questions: 1Answers: 10,234 Site admin

    Hi,

    This wasn't a limitation in the trial, but rather a bug in the version of the trial you had I'm afraid. Editor 1.7.1 shipped with an inadvertent bug that caused the create action to fail. Editor 1.7.2 fixed that (release notes), so when you purchased a license you must have then downloaded the 1.7.2 version.

    Apologies for the issue!

    Regards,
    Allan

This discussion has been closed.