我正在尝试将操作的结果呈现为模式(Twitter bootstrap )。不幸的是,我没有得到这个工作。
在每个迭代器中生成链接之前:
<g:link action="perform" id="${exerciseInstance.id}">
<h2>${fieldValue(bean: exerciseInstance, field: "title")}: (${exerciseInstance.questions.size()} Questions)</h2>
</g:link>
与其提供一个完整的新站点,不如希望以模态形式呈现测验。因此,我尝试了一个简单的twitter bootstrap模态示例:
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large">${fieldValue(bean: exerciseInstance, field: "title")}</a>
<div id="myModal" class="modal hide fade" style="display: none; ">
<div class="modal-header">
<h3>Test</h3>
</div>
<div class="modal-body">
--> This is where the content should go <--
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
实现此目标的最佳方法是什么?
请您参考如下方法:
在SO上寻求“最佳方式”是危险的游戏。可能不是最好的。只是不同的方法。我会给你一个我使用的jQuery的$.load()函数。
$("#myModal .modal-body").load(url);
真的就是这么简单。显然,如果需要传递参数,提供回调函数等,请调整load()函数。 Controller 的操作将仅呈现模态体内包含所需HTML的模板。这甚至不是Grails特有的。这种方法适用于任何服务器端技术。




