div class lightbox_wrap form action TMPL_var form_action_link method P

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<div class="lightbox_wrap">
<form action="<TMPL_var form_action_link>" method="POST" id="edit_form">
<div class="lightbox_apps">
<button class="but_close" id="modal_window_close"></button>
<div class="form_row">
<label class="label_stnd">ID</label>
<input type="text" <TMPL_if (is_edit)>disabled="disabled"</TMPL_if> name="text_id" class="in_text" value="<TMPL_var HTMLESCAPE(text_id)>" />
<div class="in_error" id="text_id_errors"></div>
</div>
<div class="form_row">
<label class="label_stnd">Заголовок</label>
<input type="text" name="name" class="in_text" value="<TMPL_var HTMLESCAPE(name)>" />
<div class="in_error" id="name_errors"></div>
</div>
<div class="form_row">
<label class="label_stnd">Контент</label>
<textarea name="text" id="text_editor" style="display: none"><TMPL_var HTMLESCAPE(text)></textarea>
<div class="in_error" id="text_errors"></div>
</div>
<div>
<div class="block_half">
<input name="save" type="submit" class="but_blue" value="Сохранить" />
</div><div class="block_half">
<input name="delete" type="submit" class="but_blue" value="Удалить" />
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript">
$('#edit_form').submit(function (e) {
e.preventDefault();
var form_data = new FormData(this);
form_data.append('text', CKEDITOR.instances.text_editor.getData());
$this = $(this);
$.ajax({
url: this.action,
data: form_data,
cache: false,
contentType: false,
processData: false,
type: 'POST',
dataType: "json",
success: function(data) {
if (!$.isEmptyObject(data.errors)) {
show_errors(data.errors);
} else
reload_page();
}
});
});
$('#modal_window_close').click(function (e) {
e.preventDefault();
$('#modal_window').addClass('close').html('');
});
$(function () {
CKEDITOR.replace('text_editor', {}, "");
});
errors_hide_callback();
</script>