Album's index.gsp
It is giving error on line no. 5, the same code I am running in as .HTML file then it is working fine but in index.jsp error is coming I do not understand why it is happening.
<div class="container-fluid"> <h3><p class="text-center">Album list</p></h3> <ul id="album" class="list-group"> <g:each var="album" in="${myvar}"> <button type="button" class="list-group-item" onClick="editalbum('${album.list}')"> <span class="badge">${album.title}</span> </button> </g:each> </ul> </div> </body> </html>
AlbumController.groovy I have def abc which takes the album list and it render it to the index page
package gtunes
import static org.springframework.http.HttpStatus.*
import grails.transaction.Transactional
@Transactional(readOnly = true)
class AlbumController {
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
def index(Integer max) {
def abc = Album.list(max:10);
render(view:"index", model:[myvar:abc]);
//params.max = Math.min(max ?: 10, 100)
//respond Album.list(params), model:[albumInstanceCount: Album.count()]
}[Grails error][1]
https://drive.google.com/open?id=0B9gjSzsLSnClRFZVbWE1MWU0aDQ here is the image of the error
There is no list for the object 'album', you probably trying to edit that one instance of the object 'album', Try this and adjust your JS code accordingly:
onClick="editalbum('${album}')"
or by id e.g.:
onClick="editalbum('${album.id}')"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments