Dave's Brain

Browse - programming tips - make div for jquery dialog

Date: 2011aug8
Language: javaScript
Platform: jQuery

Q.  I don't like manually creating <div>'s for my jQuery dialogs.
Can I do it programatically?

A.  Yes, here's a function to do that:

	function prepDialogDiv(id) {
		  if ($('#'+id).size() == 0) {
		  	$('body').append('<div id='+id+'></div>');
		  }
		  else {
			$('#'+id).html('');
		  }
	}

	function exampleUse() {
		prepDialogDiv('hello');

        	$('#hello').html('Hello!');

		$('#hello').dialog({
			width: '60%',
			height: 650,
			title: 'Hello',
			modal: true,
        	});
	
	}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: