POST form does not work when adding JS scripts in VIEWS!

61 views
Skip to first unread message

Hannah J Swystun

unread,
Nov 29, 2016, 8:53:43 AM11/29/16
to Play Framework

Hi,

I have some trouble with My POST FORM ACTIONS once I added some javascripts such as : datepicker...etc

Any idea please?
By he way, Javascripts has no relation with the Result method checkbox() in controller.....I do not know why there are conflicts between controller and js scripts!!!

Hannah J Swystun

unread,
Nov 29, 2016, 1:28:06 PM11/29/16
to Play Framework
Hi,

The probleme seems to be datatable but i do not know why !!!


  $
(function () {
   
    $
('#dt_computers').DataTable({
     
"paging": true,
     
"pagingType": 'full_numbers',
     
"lengthChange": false,
     
"searching": true,
     
"ordering": true,
     
"info": true,
     
"autoWidth": false,

   
"oLanguage": {
       
"oPaginate": {
             
"sNext": 'Next&nbsp;&nbsp;<i class="fa fa-chevron-right text-primary"></i>',
             
"sPrevious": '<i class="fa fa-chevron-left text-primary"></i>&nbsp;&nbsp;Previous',
             
             
"sFirst": '<i class="fa fa-fast-backward text-primary"></i>&nbsp;&nbsp;First',
             
"sLast": 'Last&nbsp;&nbsp;<i class="fa fa-fast-forward text-primary"></i>'
           
}
         
},

     
"bLengthChange": true,  // Showing X Entries
     
"bInfo" : true,   // hide showing x to y of z              
     
"pageLength": 10,       // nb of items per tab by default
     
"order": [[ 1, "asc" ]], // Commence à 0
     
"columnDefs": [
           
{'targets': 0,'searchable':true,'orderable':false},
           
{'targets': 7,'searchable':false,'orderable':false}
                   
] // Column Checkbox without Order
   
});
 
});

Steve Chaloner

unread,
Nov 30, 2016, 4:58:08 AM11/30/16
to Play Framework
If you open the browser console, do you see any errors reported there?

Also, try using the simplest possible datatable to see if any of your configuration is causing the issue.

$('#dt_computers').DataTable();

Hannah J Swystun

unread,
Nov 30, 2016, 11:54:17 AM11/30/16
to Play Framework
Hi Steve,

When I open Firebug, Datatable create input checkbox without giving name="xxxx" and value="yyyy"
that's why :

String[] computers = request().body().asFormUrlEncoded().get("chkItems");

Could not getting ids selected from datatable.....

is there any possibility please to modify datatable checkbox before ?


Le mardi 29 novembre 2016 13:53:43 UTC, Hannah J Swystun a écrit :

Hannah J Swystun

unread,
Dec 2, 2016, 8:20:41 AM12/2/16
to Play Framework
Solution Found :

The checkboxes are missing 'name' and 'value' attributes.
I update my view.scala.html with:
      'columnDefs': [{
         
'targets': 0,
         
'searchable': false,
         
'orderable': false,
         
'width': '1%',
         
'className': 'dt-body-center',
         
'render': function (data, type, full, meta){
             
return '<input type="checkbox" name="case" value="thevalue">';
         
}
     
}],

and it works.
I attached a sample for those who are ineterested by getting REQUEST FORM BODY from JQUERY DATABALE.
To run it :
SBT RUN.

https://drive.google.com/file/d/0B97fo89guk_nSEtwNWJGdkdTMGs/view?usp=sharing





Le mardi 29 novembre 2016 13:53:43 UTC, Hannah J Swystun a écrit :
Reply all
Reply to author
Forward
0 new messages