Skip to content

Commit

Permalink
Cast the form value before assigning it to the parameter. Fixes #28
Browse files Browse the repository at this point in the history
If the type of the parameter is "number", it will cast the value of the
input element using JS's `Number()` function.
  • Loading branch information
davidomarf committed Nov 3, 2019
1 parent 5a09f91 commit c4a0f76
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ginpar/templates/retrieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ function resetDraw(){

function updateVars(){
{% for param in params -%}
{% if param["attrs"]['type'] == 'dimensions' -%}
{%- if param["attrs"]['type'] == 'dimensions' -%}

{{ param.var }} = [
document.getElementById("{{ param.id }}-0").value,
document.getElementById("{{ param.id }}-1").value
Number(document.getElementById("{{ param.id }}-0").value),
Number(document.getElementById("{{ param.id }}-1").value)
];

{% else %}

{{ param.var }} = document.getElementById("{{param.id}}").value;

{{ param.var }} =
{%- if param.attrs.type == "number" -%} Number{%- endif -%}
(document.getElementById("{{param.id}}").value);
{%- endif %}
{%- endfor %}

Expand Down

0 comments on commit c4a0f76

Please sign in to comment.