Commit fdf6ac0b authored by Marc Ducobu's avatar Marc Ducobu
Browse files

Debug When leaving a report form page without modification, warning pop up is shown - refs #391

parent a327f581
......@@ -29,23 +29,10 @@
<button class="sc-button red margin-10" type="reset"><i class="fa fa-eraser"></i> {{ 'Reset report'|trans }}</button>
</div>
{{ form_end(edit_form) }}
<script type="text/javascript">
var form = $("form[name='{{ edit_form.vars.form.vars.name }}']").data('serialize',$("form[name='{{ edit_form.vars.form.vars.name }}']").serialize());
// On load save form current state
var submittedOk{{ edit_form.vars.form.vars.name }} = false;
form.bind('submit', function(e) {
submittedOk{{ edit_form.vars.form.vars.name }} = true;
});
{% endblock %}
$(window).bind('beforeunload', function(e){
if($("form[name='{{ edit_form.vars.form.vars.name }}']").serialize()!=$("form[name='{{ edit_form.vars.form.vars.name }}']").data('serialize')){
if (submittedOk{{ edit_form.vars.form.vars.name }} == false) {
return "{{ 'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?'|trans }}";
}
}
e=null;
// i.e; if form state change show box not.
});
{% block js %}
<script type="text/javascript">
chill.protectUnsavedDataForFrom('form[name="{{ edit_form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
</script>
{% endblock %}
......@@ -29,22 +29,10 @@
<button class="sc-button red margin-10" type="reset"><i class="fa fa-eraser"></i> {{ 'Reset report'|trans }}</button>
</div>
{{ form_end(form) }}
<script type="text/javascript">
var form = $("form[name='{{ form.vars.form.vars.name }}']").data('serialize',$("form[name='{{ form.vars.form.vars.name }}']").serialize());
// On load save form current state
var submittedOk{{ form.vars.form.vars.name }} = false;
form.bind('submit', function(e) {
submittedOk{{ form.vars.form.vars.name }} = true;
});
{% endblock %}
$(window).bind('beforeunload', function(e){
if($("form[name='{{ form.vars.form.vars.name }}']").serialize()!=$("form[name='{{ form.vars.form.vars.name }}']").data('serialize')){
if (submittedOk{{ form.vars.form.vars.name }} == false) {
return "{{ 'You are going to leave a page with unsubmitted data. Are you sure you want to leave ?'|trans }}";
}
}
e=null;
// i.e; if form state change show box not.
});
{% block js %}
<script type="text/javascript">
chill.protectUnsavedDataForFrom('form[name="{{ form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
</script>
{% endblock %}
\ No newline at end of file
Supports Markdown
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