DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Erico has posted 5 posts at DZone. View Full User Profile

Grails Taglib Para Dialog JQuery UI

09.17.2009
| 3860 views |
  • submit to reddit
        Uso:

<g:confirmDialog for="delete" title="Excluir o Registro???" action="/cargo/delete" desc="Você tens certeza que deseja excluir o registro?" />

[no form]
<span class="button"><input type="button" value="Excluir" class="delete" id="delete" /></span>

	def confirmDialog = { attrs, body -> 

		def appCtx = request.contextPath; 
	
		out << """<script type="text/javascript">
			\$(function() {
				\$("#${attrs.for}Dialog").dialog({
					autoOpen: false,
					bgiframe: true,
					resizable: false,
					height:140,
					modal: true,
					overlay: {
						backgroundColor: '#000',
						opacity: 0.5
					},
					buttons: {
						'Sim': function() {
							\$(this).dialog('close');
							document.forms[0].action='${appCtx}${attrs.action}';
							document.forms[0].submit();
						},
						'Cancelar': function() {
							\$(this).dialog('close');
						}
					}
				});
				
		                \$('#${attrs.for}').click(function() {  
                                \$("#${attrs.for}Dialog").dialog('open');
                             });  
			});
			
		</script>

		<div id="${attrs.for}Dialog" style="display: none;" title="${attrs.title != null ? attrs.title : "Confirmar" }">
			<p>${attrs.desc != null ? attrs.desc : "Tem certeza?" }</b></p>
		</div>"""
	}