html5 - Passing innerHtml value as parameter for play framework routes -


hello trying pass inline edited table value parameter play routes can me same here html code

<table class="gradienttable">         <thead>                 <tr>             <th>task</th>              <th>timesheetdate</th>             <th>hours</th>             <th>isbilled</th>              <th>work place</th>         </tr>         </thead>             <tbody>                @for(element <- currentpage) {                         <tr>                              <td contenteditable="true" id="task1">@element.gettask()</td>                  <td>@element.gettimesheetdate()</td>                  <td contenteditable="true" id="hours">@element.gethours()</td>                  <td contenteditable="true" id="isbilled">@element.getisbilled()</td>                  <td contenteditable="true"id="workplace">@element.getworkplace()</td>                 <td><a href="@{routes.application.edit(task1.innerhtml)}" ><img src="@routes.assets.at("images/edit.jpg")" alt="edit" style="width:20px;height:20px"></a>                             </tr>                     }              </tbody>         </table> 

routes

get     /application/edit            controllers.application.edit(task1:string) 

application.java

public static result edit(string task1)     {         return ok(displaytimesheet.render(task1));     } 

it looks you're confusing server-side rendered scala template dom actions of client. @{routes.application.edit(task1.innerhtml)}, task1 doesn't exist far non-dom template concerned.

your use of <a href="..."> kind of weird, because make synchronous call , if you're inline editing maybe that's not want. answer covers asynchronous approach using play's javascript router support (which, if haven't seen before, cool).

you'll need expose edit in javascript router:

// can return f.promise<result> public static result jsroutes() { response().setcontenttype("text/javascript"); return ok(routes.javascriptrouter("approutes", //approutes js object available in our view                                   routes.javascript.application.edit())); 

}

and expose method in routes:

get           /assets/js/routes             controllers.application.jsroutes() 

that generate chunk of javascript can import

<script src="@controllers.routes.application.jsroutes()" type="text/javascript"></script> 

and finally, write javascript handle inline editing completion.

function doinlineedit(taskname) {     approutes.controllers.application.edit(taskname).ajax( {       success : function ( data ) {         target.closest('li').remove();       }     }); } 

then need wire method called when inline-editable element changes content.

you can find additional info here.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -