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

Done task #29

Add page for departments
parent 1071f906
Branches
Tags
No related merge requests found
p{
color: #0000cc;
}
\ No newline at end of file
$(function () {
var button = $('#button');
button.click(function () {
var num = ($('input').first().val());
// grade/~dev_rating
$.get(URLdir + '/departments/' + num, function (res) {
$('#container').html(res);
});
});
});
\ No newline at end of file
/**
* Created by ami96_000 on 02.07.2015.
*/
$(function(){
var faculty=$('#faculty');
faculty.change(function () {
alert(
faculty.find('option:selected').val());
});
});
\ No newline at end of file
......@@ -280,3 +280,12 @@ Route::set('javaSessionProvider', 'java_authentication')
'controller' => 'JavaAuthentication',
'action' => 'authentication'
]);
Route::set('departments:main', 'departments(/<id>)', ['id' => '[0-9]+'])
->defaults([
'controller' => 'Departments', // classes/Controller/Departments.php
'id' => 1,
]);
// bars.com/departments
// bars.com/departments/78
\ No newline at end of file
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Departments extends Controller
{
public function action_index() {
$id = (int) $this->request->param('id');
$name = $this->request->is_ajax() ? 'departments' : 'main_departments';
$twig = Twig::factory($name, [
'Departments' => Model_Faculty::with($id)->getDepartments()
]);
$this->response->body($twig);
}
}
<ul>
{% for d in Departments %}
{% if d.Name != '' %}
<li value="{{ d.ID }}">{{ d.Name }}</li>
{% endif %}
{% endfor %}
</ul>
\ No newline at end of file
<html>
<head>
{{ HTML.script('static/js/libs/jquery-1.11.1.min.js') |raw }}
{{ HTML.script('static/js/button.js')|raw }}
{{ HTML.script('static/js/config.js')|raw }}
</head>
<body>
<p>Введите id факультета:</p>
<input type="text" size="3" name="num" min="1" max="10" value="0">
<button id="button">OK</button>
<p>Список кафедр:</p>
<div id="container">
<ul>
{% for d in Departments %}
{% if d.Name != '' %}
<li value="{{ d.ID }}">{{ d.Name }}</li>
{% endif %}
{% endfor %}
</ul>
</div>
</body>
</html>
{#<select>
{% for f in Faculties %}
<option value="{{ f.ID }}">
{{ f.Name }}
</option>
{% endfor %}
</select>#}
{# <select id="faculty">
<option value="1">мимими</option>
<option value="2">урурру</option>
<option value="3" class="mytext">:3</option>
<option>ROOOOOAAAR</option>
</select>
<p>
meow
</p>
<p class="mytext">ROAR</p>#}
\ 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