Вход

Просмотр полной версии : не работает .submit в .dialog


victor256
13.06.2012, 11:57
Добрый день! Сделал форму для заполанения через .dialog. При нажатии кнопки "сохранить" ничего не происходит. Подскажите, почему?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/flick/jquery.ui.all.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// ----------------------------------------------
$( "#add_form" ).dialog({
autoOpen: false,
closeOnEscape: true,
modal: true,
buttons: {
"Сохранить": function() {
$(this).dialog("close");
$('#form1').submit(function(){
alert('Форма form1 отправлена на сервер');
return false;
});
},
"Отмена": function() {
$(this).dialog("close");
}
}
});

$('button').button();

$('#add_button').click(function() {
$("#add_form").dialog("open");
});
// ----------------------------------------------
});
</script>
</head>

<body>

<button id="add_button">Добавить событие</button>

<form id="form1" method="post" action="sdfsdf.html">
<input type="hidden" name="action" value="add" />

<table id="add_form" title="Добавить">
<tr>
<td>input #1:</td>
<td><input type="text" name="date" value="13.06.2012" /></td>
</tr>
<tr>
<td>input #2:</td>
<td><input type="text" name="name" /></td>
</tr>
</table>
</form>

</body>
</html>