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

61 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Hannah J Swystun

ungelesen,
29.11.2016, 08:53:4329.11.16
an 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

ungelesen,
29.11.2016, 13:28:0629.11.16
an 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

ungelesen,
30.11.2016, 04:58:0830.11.16
an 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

ungelesen,
30.11.2016, 11:54:1730.11.16
an 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

ungelesen,
02.12.2016, 08:20:4102.12.16
an 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 :
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten