StackOverflow
When a div is converted into a modal using a .dialog(), the title attribute of the div is used as the title of the Modal
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/cupertino/jquery-ui.css">
<div data-title="Modal Title" data-modal="1" class="filter"><p>Modal Text</p></div>
<div data-title="Another Modal Title" data-modal="1" class="filter"><p>Another Modal Text</p></div>
<div class="filter"><p>Not a Modal</p></div>
<div data-title="Modal Title" data-modal="1" class="each"><p>Modal Text</p></div>
<div data-title="Another Modal Title" data-modal="1" class="each"><p>Another Modal Text</p></div>
<div class="each"><p>Not a Modal</p></div>
JavaScript
$(function() {
$('div.each').each(function(index, item) {
if ($(item).data('modal') == 1) {
$(item).dialog({
title :$(this).data('title'),
position:'top'
});
}
});
});