Meteor and Editor DataTables and Inline Edit

Meteor and Editor DataTables and Inline Edit

hhsiaohhsiao Posts: 12Questions: 4Answers: 0

Hi Alen,

I've been successful in implementing inline edit with Meteor. Problem is I can only do it once, after which I get following failure:
jquery.js:1491 Uncaught Error: Syntax error, unrecognized expression: #ObjectID("5746ce5e7f64dd8e5dc0ac85")

Can you explain to me exactly what I should pass into successCallback?

Regards,

Henry

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Hi Henry,

    The JSON return from the server is documented here - that JSON is what should be given to the success callback in ajax.

    The error you are seeing occurs if a selector is used with characters that have special meaning. For example in the above, it sounds like that whole string (ObjectID("5746ce5e7f64dd8e5dc0ac85")) is what has been applied as your row ids. Is that correct?

    Allan

  • hhsiaohhsiao Posts: 12Questions: 4Answers: 0

    I believe the purpose of the JSON is for Editor to properly update the display?
    I am running Meteor, ObjectID("5746ce5e7f64dd8e5dc0ac85") is the Mongo DB id column.

    I am actually using https://github.com/aldeed/meteor-tabular which automatically updates the display in reaction to any data changes, so I think that makes the passing of JSON redundant.

    Is there way to skip this portion of the update? I got it working currently but it is completely ghetto (described below):

    initEditor = function() {
        // Codes to initialize the editor
        ajax: function (method, url, data, successCallBack, errorCallBack ) {
            var output = {data: []};
            // Call server via WebSocket
            // ~~~~~
            try {
                successCallBack( output );
            }
            catch (error) {
                initEditor();
            }
        }
    }
    

    Soo... the above actually gets me exactly what I want... I however kinda feels a bit dirty for doing such a ghetto hackery.

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Answer ✓

    Can you strip the ObjectID("") part? That would make it a valid ID selector.

    Allan

  • hhsiaohhsiao Posts: 12Questions: 4Answers: 0

    I just realize what I did with re-initializing only works for inline editing, not bubble editing.

    My data looks like:

    meteor:PRIMARY> db.ResourceSchedule.find()
    { "_id" : ObjectId("57485be85b42aa470a4f66dd"), "resourceName" : "John Li", "date_05202016_client" : "OH Shit", "date_05202016_ticket" : "3234", "date_05202016_type" : "Deployment", "date_05202016" : "d" }
    { "_id" : ObjectId("5748522e5b42aa470a4f66db"), "resourceName" : "Henry Hsiao", "date_05202016_client" : "Tecala", "date_05202016_ticket" : "1234", "date_05202016_type" : "Deployment", "date_05252016_client" : "Test", "date_05252016_ticket" : "123", "date_05252016_type" : "Report" }
    

    The field _id gets displayed (but hidden) on the datatable, when you say strip, do you mean from the backend? or purely just the frontend? I'll continue to poke around at this, I feel like I am getting closer to actual solutions :)

  • hhsiaohhsiao Posts: 12Questions: 4Answers: 0

    Hi Allan,

    Great news, your suggestion worked!! I simply created a new field that doesn't use ObjectId.

    For anyone else that happen to find this thread. The exact fix is:

    All insert into Mongo DB have a "uid" field, where the values goes like this:
    db.ResourceSchedule.insert({"uid":ObjectId().str, resourceName: "Alice"})

    After which use uid for the editor idSrc: 'uid',

    Thanks again Allan!

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    That's awesome - thanks for posting back with your solution!

    Regards,
    Allan

  • soclbzsoclbz Posts: 2Questions: 1Answers: 0

    @hhsiao , how did you integrated editor with meteor tabular? Can you please help me for the same. Please share sample code if possible.

  • rhsu0268rhsu0268 Posts: 5Questions: 1Answers: 0

    @soclbz: @hhsiao: I am trying to do the same with the Meteor framework. Can you let me know where you included the datatables.editor.js file?

    I am also using the aldeed, meteor-tabular and want it to play well with it.

    Thanks so much.

This discussion has been closed.