Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable js createlement in render function #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

icepower03
Copy link

this change allows to make this ( the click event in particular)

// extract from the datatable column definition in full js
{
title: "accès bureau de prescription",
render: function (data, type, row, meta)
{
return $('

', {
text: "Presc. V5",
class: 'ouvrirPrescV5'
})
.click(function () { lancerBureau(row); })[0];
}
},

i think that the click event should be chained and not triggered with a new selector on tbody which to recreate the data() object.

so i can make it work like that but i think that it's not logical /or/ the most efficient way
.on('click', 'tbody .ouvrirPrescV5', function () {

     var dt = monTableau.row($(this).parents('tr')).data();
     lancerBureau(dt);
  });

//the idea is to full manage the contenent of the cell including events
// if you have another way to do such, this change is useless but as i see that the innerHTML is used to insert content in td i think that only dom strings are accepted and not dom objects.

this change allows to make this ( cthe click event in particular)

 {
              title: "accès bureau de prescription",
              render: function (data, type, row, meta)
              {
                  return $('<div/>', {
                      text: "Presc. V5",
                      class: 'ouvrirPrescV5'                      
                  })
                .click(function () {  lancerBureau(row); })[0];
              }
          },


beacause i think that in a full javascript data use of datatable  it's not logical to work with selector like this:
  .on('click', 'tbody .ouvrirPrescV5', function () {

         var dt = monTableau.row($(this).parents('tr')).data();
         lancerBureau(dt);
      });

//the idea is to full manage the contenent of the cell including events
// if you have another way to do such, this change is useless but as i see the innerHTML
@DataTables
Copy link
Collaborator

Thanks for the PR. The issue with this is that it might break the extensions such as Buttons etc, which don't expect a jQuery object. It could also cause issues for type detection and filtering, which again, don't expect a jQuery object.

I'm afraid I don't think I can pull this in at this time.

Having said that, being able to return a jQuery object (or DOM node) is something I plan to add in the next major version of DataTables - but its going to take some careful thought.

@icepower03
Copy link
Author

ok thanks for your reply, i let you think about it.

@milux
Copy link

milux commented Apr 21, 2016

This is basically a less powerful alternative to the technique I suggested over one your before you came up with your suggestion, see advanced rendering #19

@milux
Copy link

milux commented Apr 21, 2016

Plus - as far as I can tell - my approach doesn't suffer from the problem(s) mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants