Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82273

Editor KeyTable integration documentation change suggestions

$
0
0
I am picking up enough JS to do some reasonable troubleshooting of my own, in no small part thanks to Allan's help with DataTables.
I just went through the KeyTable/Editor integration documentation here: http://editor.datatables.net/tutorials/keytable

I'd like to suggest 2 changes:
1) Mention joined table columns end with ".id" (or whatever the JSON uses, but the docs use ID).
For example, the call to the showField function, if it's being used, looks like:
showField(editor, keys, 'oneToOneColumnName.id');
or
showField(editor, keys, 'oneToManyColumnName[].id');
This isn't that unexpected -- the .update call in "fnInitComplete" used to populate the form values is the same, but this wasn't fresh in my mind and to me was not immediately obvious.
This applies to the "Creating a form using the API" tutorial as well.


2) The code used to handle the Enter and Escape keys never did work for me:
$(window).bind('keydown', function (e) {
    if ( e.keyCode === 13 ) {
        // On return, submit the form
        editor.submit();
    }
    else if ( e.keyCode === 27 ) {
        // On escape, close the form
        editor.close();
    }
} );

No event ever fired, no matter the key I pressed. Maybe a bug of mine, maybe not, but the jQuery docs for ".bind" (http://api.jquery.com/bind/) suggest that .on() is now the preferred means of binding events, so I suggest something like the following, which worked for me:
$("body").on("keypress",function(e){
	if(e.keyCode === 13) {
		// On return, submit the form
		editor.submit();
	}
	else if(e.keyCode === 27) {
		// On escape, close the form
		editor.close();
	}
});

Viewing all articles
Browse latest Browse all 82273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>