Cannot call method 'fnSelectNone' of null

Cannot call method 'fnSelectNone' of null

INTONEINTONE Posts: 153Questions: 58Answers: 6
edited June 2014 in Editor

I have this simple function that runs on preSubmit to check if at least one check box is checked and then post an error message. It works fine in create and edit state but not delete. Is there a way to not have this called for a delete or just to get the fnSelectNone to not be called?

   editor.on( 'preSubmit', function ( e, o, a ) {



       if(a == "edit" || a == "create"){ 
       /// console.log(_.pluck(o, 'rights_management'));
       //get all the element name and check if any of the checkboxes have a value using underscore
        var continue_process = false;
        $.each(_.pluck(o, 'rights_management'),function(i,v){

        if(i == 1){

           $.each(v,function(i,k){
            console.log(i +" - "+ k);
            if(i.split("_",1) == "read" || i.split("_",1) == "write" || i.split("_",1) == "delete"){
             if(k.length > 0){
              continue_process = true;
              return false;
             }
            }
           })

        }


        });

       if(continue_process == false){


        noty({"text":"Please check at least one user right!","layout":"top","type":"error"});
            return false;
       } else {
         o.data.rights_management.datetime_updated = moment().format("YYYY-MM-DD H:mm:ss");
         return true;
       }

      }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    It look alike that already be the case as you have if (a == "edit" || a == "create") { at the top of the function. In the remove class, it should be a==='remove' and therefore that code won't run.

    I guess that isn't the case here. Can you link to the page? If so, I'd suggest adding some debug to check the value of a for the delete action.

    Allan

  • INTONEINTONE Posts: 153Questions: 58Answers: 6

    I did a console.log(a) and it gave me a === "remove":

     } else if(a === "remove"){
              console.log(a);
           //i got "remove"
     }
    

    so therefore there is no way to not have the delete action run on the preSubmit event. Is there a way to force "fnSelectNone" to not be called before it is?

  • INTONEINTONE Posts: 153Questions: 58Answers: 6

    To fix this I had to edit the dataTables.editor.js file. I comment out line 4998

    //tt.fnSelectNone(); 
    

    that seem to have fixed the issue. What is the worst thing that can happen if this is commented out?

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    Answer ✓

    That seems a little odd - that line will deselect the selected nodes when there are deleted so TableTools doesn't have a reference to them. Without that there is a disconnect between the state of the table and the TableTools buttons.

    There much be something else going on - I'm surprised that the check for remove doesn't work. Can you link me to the page so I can take a look and debug it?

    Regards,
    Allan

  • INTONEINTONE Posts: 153Questions: 58Answers: 6

    Is there a way to send you a private message with the link?

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
This discussion has been closed.