From d41fdb28153a0536da47b33a89619f4a1da269de Mon Sep 17 00:00:00 2001 From: sidya82 Date: Thu, 19 Feb 2015 16:50:36 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20SRC/app/Http/Controllers/ReferentController.php=20=09modifi?= =?UTF-8?q?=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20SRC/public/js/getListeO?= =?UTF-8?q?euvre.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/ReferentController.php | 3 ++- SRC/public/js/getListeOeuvre.js | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/SRC/app/Http/Controllers/ReferentController.php b/SRC/app/Http/Controllers/ReferentController.php index 2fcd8fb..ec1c04f 100755 --- a/SRC/app/Http/Controllers/ReferentController.php +++ b/SRC/app/Http/Controllers/ReferentController.php @@ -5,6 +5,7 @@ use Input; use Request; use App\ListeOeuvre; use App\AssoListeAOeuvre; +use Response; class ReferentController extends Controller { @@ -82,7 +83,7 @@ class ReferentController extends Controller { public function showListeOeuvres($id) { - return $listeoeuvres = ListeOeuvre::currentUser()->get()[0]->oeuvres()->toJson(); + return Response::json(ListeOeuvre::currentUser()->get()[0]->oeuvres->toArray()); } public function deleteListeOeuvre() diff --git a/SRC/public/js/getListeOeuvre.js b/SRC/public/js/getListeOeuvre.js index 4ed57e1..4333404 100644 --- a/SRC/public/js/getListeOeuvre.js +++ b/SRC/public/js/getListeOeuvre.js @@ -1,19 +1,20 @@ $(document).ready( function() { - - $( '.listeoeuvre' ).click(function(this) { - id = $(this).$('.idListeOeuvre').val(); - $.get("showListOeuvres/"+id, function( data ) { + console.log( "document loaded" ); + $('.listeoeuvre').click(function() { + url = "/showListOeuvres/" + $(this).children('.idListeOeuvre').val(); + $.get(url, function( data ) { data.forEach( function(el) { $("#oeuvrePic").append('
') .append(''); - }) + }) + }, "json" ) + + .fail(function() { + console.log( "error" ); }); - - //prevent the form from actually submitting in browser - return false; - } ); - -} ); + }); +}); +