Editor.Bubble row ID

Editor.Bubble row ID

bjshortybjshorty Posts: 20Questions: 6Answers: 0

I'm trying to get the data (row ID) from the row that I am currently editing using the bubble editor and display it inside the bubble form.

$('#example').on('click', 'tbody td:not(:first-child)', function (e) {

    var modifier = editor.modifier();

    if(modifier){
        var data = table.row(modifier).data();
 
        editor.bubble(this,{
            message: 'Hello'+data,
            button: 'Update',
        });
    }
});

Apparently this code is not working for me. How can I simply display the row id?

Thank you

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    data is presumably an object or and array, so you would probably use

    • message: 'Hello '+data.id (objects with an id property)
    • message: 'Hello '+data[0] (arrays with id in index 0)

    You could use console.log( data ) to check the structure of that data.

    Allan

  • bjshortybjshorty Posts: 20Questions: 6Answers: 0

    For some reason, the IF statement is not working, so I had to eliminate it. Now, the code:

    message: 'Hello '+data.id works like a charm, but i'm receiving only the value of the column named id for the first row regardless of where I click.

    How can I get the the same value but for the specific row that I click? Also, the Editor.bubble only opens once. If I try to Bubble Edit another field It won't open.

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    What you say suggests that modifier might be undefined. Is that the case?

    Can you give me a link to the page so I can try to debug it please?

    Allan

  • bjshortybjshorty Posts: 20Questions: 6Answers: 0

    I'll be sending it via email

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Ah I see the issue - thanks for the link.

    The problem is that you are calling modifier() before editing has been activated. So there is no modifier...

    I believe the code should be:

    $('#example').on('click', 'tbody td:not(:first-child)', function (e) {
      var tr = $(this).closest('tr');
      var data = table.row(tr).data();
    
      editor.bubble(this, {
        message: 'Edit: ' + data.employee_id,
        button: 'Update'
      });
    });
    

    Allan

  • bjshortybjshorty Posts: 20Questions: 6Answers: 0

    Wow! Works perfectly! Thank you so much

This discussion has been closed.