Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to delete the uploaded image
    primarykey
    data
    text
    <p>HTML/GSP</p> <pre><code>&lt;li class="gallery-item"&gt; &lt;form&gt; ..... &lt;a data-portfolio-id="${portfolioInstance?.id}" data-id="${part.id}" class="btn-delete" href="javascript:void(0);"&gt; &lt;/form&gt; &lt;/li&gt; </code></pre> <p>JS</p> <pre><code>$('.btn-delete').click(function(e){ e.preventDefault(); $.ajax({ url: '/deletePart/'+ $(this).data('id'), type: 'GET', dataType: 'json', success: function(response) { $(this).closest('.gallery-item').fadeOut().remove(); //remove() seems not to be working? }, error: function( error ) { console.log( error ); } }); }); </code></pre> <p>Controller</p> <pre><code> def deletePart() { log.debug params def id = params.id?:params.partId def part = PortfolioPart.get(id) // log.debug " &gt;&gt;&gt;&gt;&gt;&gt;" + part def portfolio = part.portfolio try { part.delete(flush: true) flash.message = message(code: 'default.deleted.message', args: [message(code: 'part.label', default: 'PortfolioPart'), id]) } catch (DataIntegrityViolationException e) { flash.message = message(code: 'default.not.deleted.message', args: [message(code: 'portfolio.label', default: 'Portfolio'), id]) redirect(action: "edit", id: portfolio.id) } withFormat { html { redirect(action: "edit", id: portfolio.id) } json { def out = [id:id] render out as JSON } } } </code></pre> <p>Tried to remove the image with its id that was uploaded previously, but it keeps giving me 500 internal server error. </p> <p><strong>GET http://localhost/deletePart/[220]500 (internal server error)</strong></p> <p>Any help is appreciated!</p> <p><strong>Update</strong> Ok managed to get the error go away, but only left is remove() that doesn't remove the gallery-item block?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload