angularjs - How to refresh the form to its previous non data state once the data has been submitted -
i having form scenario user select 1 form multiple forms , starts fill it. after filling when he/she clicks on submit button data posted server , server after successful operation returns status ok showing user pop user confirmation. when user clicks on ok button on pop up, want show user, same form again fill. form need refreshed. how done angularjs. developing app in cordova ionic framework , has angularjs in it.
my form div this:
<form name="fieldform" method="post" ng-submit="submitformdata($event, htmlvalue)"> <div class="bootstrap" ng-bind-html="htmlvalue.html | unsafe"> ......form html....... </div> <div class="padding"> <button class="button button-block button-calm"> submit </button> </div> </form>
my controller looks this:
var formid = html.id; var url = base_url+"put/putformfilledrawdata.php"; var data = $(obj.target).serialize(); $http.post(url, data). success(function(data, status, headers, config) { if(data.alert == 'success'){ var mypopup = $ionicpopup.show({ title: 'confirmation', subtitle: 'your data has been submitted successfully', scope: $scope, buttons: [ { text: '<b>ok</b>', type: 'button-calm', ontap: function(e) { $(this).hide(); } }, ] }); }else{ var mypopup = $ionicpopup.show({ title: 'error report', subtitle: 'unknown error has been occurred', scope: $scope, buttons: [ { text: '<b>ok</b>', type: 'button-calm', ontap: function(e) { $(this).hide(); } }, ] }); }
what need reset form. can use reset function via plain javascript this
document.getelementbyid("form_id").reset();
or using jquery this
$('#form_id').trigger("reset");
you can call function in close pop function of modal.
Comments
Post a Comment