Finished book adding feature.
Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
		| @@ -15,7 +15,7 @@ use KekRozsak\FrontBundle\Form\Type\BookType; | |||||||
| class BookController extends Controller | class BookController extends Controller | ||||||
| { | { | ||||||
|     /** |     /** | ||||||
|      * @Route("/konyvtar", name="KekRozsakFrontBundle_bookList") |      * @Route("/konyvtar", name="KekRozsakFrontBundle_bookList", options={"expose" = true}) | ||||||
|      * @Template() |      * @Template() | ||||||
|      */ |      */ | ||||||
|     public function listAction() |     public function listAction() | ||||||
| @@ -46,7 +46,7 @@ class BookController extends Controller | |||||||
|                 $em->persist($book); |                 $em->persist($book); | ||||||
|                 $em->flush(); |                 $em->flush(); | ||||||
|  |  | ||||||
|                 return new Response(); |                 return new Response('success'); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -155,8 +155,8 @@ $('.book-row').click(function() { | |||||||
|             bookid = $(this).attr('id').replace(/^want-to-(buy|borrow)-button-/, ''); |             bookid = $(this).attr('id').replace(/^want-to-(buy|borrow)-button-/, ''); | ||||||
|             url = Routing.generate('KekRozsakFrontBundle_bookWantOne', { id: bookid, wantToBuy: toBuy }); |             url = Routing.generate('KekRozsakFrontBundle_bookWantOne', { id: bookid, wantToBuy: toBuy }); | ||||||
|             $.ajax({ |             $.ajax({ | ||||||
|                 method: 'GET', |                 type: 'GET', | ||||||
|                 url:    url |                 url:  url | ||||||
|             }).done(function() |             }).done(function() | ||||||
|             { |             { | ||||||
|                 doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); |                 doPopup('', 'Betöltés...', bookUrl, 400, 300, bookCallback); | ||||||
| @@ -172,7 +172,17 @@ $('.book-row').click(function() { | |||||||
|  |  | ||||||
| function setupAjaxBookForm() | function setupAjaxBookForm() | ||||||
| { | { | ||||||
|     $('#new-book-form').ajaxForm(); |     $('#new-book-form').ajaxForm({ | ||||||
|  |         target:        '#new-book-form-result', | ||||||
|  |         replaceTarget: true, | ||||||
|  |         success:       function(data) { | ||||||
|  |             if (data == 'success') { | ||||||
|  |                 // TODO: Reload the book list with an AJAX request instead of | ||||||
|  |                 // reloading the page. | ||||||
|  |                 window.location = Routing.generate('KekRozsakFrontBundle_bookList'); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| $('.new-book-button').click(function() { | $('.new-book-button').click(function() { | ||||||
| @@ -185,10 +195,7 @@ $('#new-book-form').on('submit', function(e) { | |||||||
|  |  | ||||||
|     $(this).ajaxSubmit({ |     $(this).ajaxSubmit({ | ||||||
|         target:        '#new-book-form-result', |         target:        '#new-book-form-result', | ||||||
|         replaceTarget: true, |         replaceTarget: true | ||||||
|         success:       function(data) { |  | ||||||
|             alert(data); |  | ||||||
|         } |  | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
| </script> | </script> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user