james riady james riady - 24 days ago 7
HTML Question

How to refresh page in modal


function createNewCategory(idx){
var modal = $('#category').modal();
url: "<?php echo url('/category') ?>",
type: "POST",
dataType : 'json',
success : function(data){
var app = '<option selected="" value="'+data.CategoryID+'">'+data.CategoryName+'</option>';
$('.cats-' + idx).append(app);
$('.cats-' + idx).multiselect();
return false;

Modal Form (HTML)

<div class="modal fade" id="category">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Kategori baru</h4>
<div class="modal-body">
<form class="form-horizontal" id="category-form" enctype="multipart/form-data">
{{ csrf_field() }}
<ul class="nav nav-tabs language" role="tablist" id="myTab" >
@foreach($languages as $language)
<li name="LanguageName" class="{{$language->id == 1 ? 'active' : ''}}"><a href="#catlang-{{$language->id}}" data-toggle="tab">{{$language->LanguageName}}</a></li>
<div class="tab-content">
@foreach($languages as $language)
<div class="tab-category tab-pane fade {{$language->id == 1 ? 'in active' : ''}}" id="catlang-{{$language->id}}">
<label>Nama Kategori <span class="required">*</span></label>
<input type="text" name="CategoryName[{{$language->id}}]" class="form-control" required></input>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary ok">OK</button>

After I input something in "input text" then I close and I open the modal again.. The modal page does not refresh and It makes me get the value of input text before.. How to refresh the modal?

Answer Source

You need to clear all fields in modal. As answered in Clear modal fields after close it

Just use one-type selector on each modal window field