Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/creactiweb/_templates/templates/_helpers.html
blob: 18d7fbb135e1b02ab8c623aa4be42f7c6db6e80b (plain)
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
{% macro link_to(text, endpoint) -%}
    <a href="{{ url_for(endpoint, **kwargs) }}">{{ text }}</a>
{%- endmacro %}

{% macro options(_, name, option_list, current, action) -%}
    <div id='{{ name }}'>
        <h3>{{ _(name) }}</h3>
        <form name='{{ name }}' action='{{ action }}' method="post">
            {% for opt in option_list %}
            <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br />
            {% endfor %}
            <input type="submit" value="submit" ></input>
        </form>
    </div>
{%- endmacro %}

{% macro options_ajax(_, name, option_list, current, action) -%}
    <div id='{{ name }}'>
        <h3>{{ _(name) }}</h3>
        <form name='{{ name }}'>
            {% for opt in option_list %}
            <input type='radio' name='{{ name }}' value='{{ opt }}' {% if opt == current %}checked{% endif %} />{{ _(opt) }}<br />
            {% endfor %}
        </form>    
		<script>
		<!--
		$(document).ready(function() {
	    	$("#{{ name }} input[type='radio']").change( function() {
	    		$.ajax({
	    			url: '{{ action }}',
  					type: 'POST',
  					data: ({ '{{ name }}' : $(this).val()}),
  					success: function(data) {
                            var _el = $('#{{ name }}-result');
    						_el.html(data.result);
  						}
					});
	    	});
		});
		-->
		</script>
    </div>
{%- endmacro %}