ajax - grails render template is not responding correctly -
i using grails 2.4.3. have ajax call list of object. list ok. has 10 elements. problem when want send list model not behaving correctly. nothing generated in g:each block in template although have 10 records. can please me on please? here attempts below ::
my ajax call >>>
$.ajax({ type:'post', data:{id: 1}, url:'/mdnote/getcaretopictemplate/', success:function(data,textstatus){ $modal.find('.modal-body').empty().append(data); $modal.find('.modal-title').empty().append(cfg.title); $modal.modal('show'); }, error:function(xmlhttprequest,textstatus,errorthrown){}, complete:function(xmlhttprequest,textstatus){} });
my controller action >>>
def getcaretopictemplate() { def caretopiclist = mdnoteservice.caretopiclist() render(template: '/md/patient/existingtemplateradiodiv', model: [caretopiclist: caretopiclist]) }
my template >>>
<div class="row" id="existingtemplateradiodiv"> <div class="form-group" style="margin-left: 10px;"> hello , outer text. <g:each in="${caretopiclist}" var="caretopiclist" status="i"> inner text. </g:each> </div> </div>
my list in ide console >>>
in view page after render template >>>
you need change name you're giving var
in <g:each>
tag. you're telling use same variable, caretopiclist
, you're iterating over. below should trick.
<g:each in="${caretopiclist}" var="caretopic" status="i">
Comments
Post a Comment