Jquery passing id to controller Play Framework

154 Views Asked by At

I'm having trouble trying to pass an "id" on-click to my controller. It never actually gets past jsRoutes to alert. The idea was onclick, add a border style, and then send the item that was clicked (the id). Any help would be greatly appreciated.

<script>
$('.select_it').on('click', function(e){
    var id = $(this).attr('id');

    $(this).toggleClass('myState');
    jsRoutes.controllers.Builder.selectOption(id).ajax({});

    alert(id);
        });
</script>

ROUTES FILE:

PUT /category/option/:id        controllers.Builder.selectedOption(id:Long)

GET     /assets/javascripts/routes  controllers.Builder.javascriptRoutes()

JAVASCRIPT ROUTES:

public static Result javascriptRoutes() {
    response().setContentType("text/javascript");
    return ok(
      Routes.javascriptRouter("jsRoutes",
        controllers.routes.javascript.Builder.selectedOption()
      )
  );
}
0

There are 0 best solutions below