diff options
Diffstat (limited to 'creactiweb/_templates/templates/_helpers.html')
-rw-r--r-- | creactiweb/_templates/templates/_helpers.html | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/creactiweb/_templates/templates/_helpers.html b/creactiweb/_templates/templates/_helpers.html new file mode 100644 index 0000000..18d7fbb --- /dev/null +++ b/creactiweb/_templates/templates/_helpers.html @@ -0,0 +1,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 %} |