Skip to content
Snippets Groups Projects
Commit 9b598943 authored by ElenaMetelitsa's avatar ElenaMetelitsa
Browse files

Fixed bug with loading elements

parent dcdc615d
Branches
Tags
No related merge requests found
$(function () {
var button = $('#button');
button.click(function () {
var num = ($('input').first().val());
// grade/~dev_rating
$.get(URLdir + '/studygroups/' + num, function (res) {
$('#container').html(res);
});
});
});
\ No newline at end of file
......@@ -288,4 +288,11 @@ Route::set('departments:main', 'departments(/<id>)', ['id' => '[0-9]+'])
]);
// bars.com/departments
// bars.com/departments/78
\ No newline at end of file
// bars.com/departments/78
Route::set('groups:main','studygroups(/<id>)', ['id' => '[0-9]+'])
->defaults([
'controller' => 'StudyGroups',
'action' => 'index',
'id' => 1,
]);
\ No newline at end of file
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_StudyGroups extends Controller
{
public function action_index() {
$id = (int) $this->request->param('id');
$name = $this->request->is_ajax() ? 'studygroups' : 'main_studygroups';
$twig = Twig::factory($name, [
'Groups' => Model_Students::ofGroup($id, 2)
]);
$this->response->body($twig);
}
}
<html>
<head>
{{ HTML.script('static/js/libs/jquery-1.11.1.min.js') |raw }}
{{ HTML.script('static/js/button_groups.js')|raw }}
{{ HTML.script('static/js/config.js')|raw }}
</head>
<body>
<p>Список групп:</p>
<div>
<select>
{% for g in Groups %}
{% if g.Name != '' %}
<option value="{{ g.ID }}">{{ g.Name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div>
<ul>
{% for s in Students %}
{% if s.Name != '' %}
<li value="{{ s.ID }}">{{ s.Name }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
</body>
</html>
<select>
{% for s in Students %}
{% if s.Name != '' %}
<option value="{{ s.ID }}">{{ s.Name }}</option>
{% endif %}
{% endfor %}
</select>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment