在请求模态不工作之后jquery ajax

时间:2015-11-06 19:48:47

标签: jquery twitter-bootstrap

当我点击按钮与类.btn-edit时,模态出现,但是当我 如果我单击按钮进行模态,则在此之后提交ajax请求 莫代尔没有表现出来。我需要刷新页面才能再次使用它。 控制台日志错误:未捕获的TypeError:$(...)。modal不是函数

    $(".btn-edit").click(function () {
    $('#edit-profile').modal('toggle');
    $(".update-form").submit(function(s){
        s.preventDefault();

        var website_name = $('input[name=website_name]').val();
        var website_url = $('input[name=website_url]').val();
        var type = $('#type option:selected').val();
        var category = $('#category option:selected').val();
        var sells = $('input[name=sells]').val();
        var location = $('input[name=location]').val();
        var payment = $('input[name=payment]').val();
        var description = $("textarea#message").val();

        $('#edit-profile').modal('hide');

        setTimeout(function(){
            $.ajax({
            type: "POST",
            url: "advertiser/update",
            data: {
                _token: token, website_name: website_name, website_url: website_url, type: type, category: category, sells: sells, location: location, payment: payment, description: description

            },



            success: function(data) {


                $('.wrapper').html(data);

            },

            error: function(data) {

            }
})

    },1000);

    });

});

HTML

 <button class="btn btn-info pull-right btn-edit">Edit</button>

 <div class="modal fade" class="profile" id="edit-profile" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" ><span aria-hidden="true">X</span><span class="sr-only"></span></button>
                <h3 class="modal-title" id="lineModalLabel">Edit Shop Information</h3>
            </div>
            <div class="modal-body">
                {!! Form::open(array('url'=>'advertiser/update','files'=>true , 'class'=>'update-form','id'=>'update-form','method'=>'POST')) !!}
                @foreach($shop as $shops)
                <div class="form-group col-lg-6">
                    <label>Shop Name</label>
                    <input type="textbox" name="website_name" class="form-control" id="" value="{!! $shops->website_name !!}">
                </div>
                <div class="form-group col-lg-6">
                    <label>Shop URL</label>
                    <input type="textbox" name="website_url" class="form-control" id="" value="{!! $shops->website_url !!}" placeholder="www.shop.com or www.facebook.com/shopname">
                </div>
                <div class="form-group col-lg-6">
                    <label for="type">Shop Type</label>
                    <select class="form-control" id="type" name="type">
                        <option value="{!! $shops->type !!}">{!! \App\Library\Category::type($shops->type) !!}</option>
                        <option value="Online Shops">Online Shop</option>
                        <option value="Online Marketplaces">Online Marketplaces</option>
                        <option value="Group & Deal Website">Group & Deal Website</option>
                        <option value="Social Shops"> Social Shops</option>
                    </select>
                </div>
                <div class="form-group col-lg-6">
                    <label for="category">Shop Category</label>
                    <select class="form-control" id="category" name="category">
                        <option value="{!! $shops->category !!}">{!! \App\Library\Category::category($shops->category) !!}</option>
                        <option value="Electronic & Gadgets">Electronic & Gadgets</option>
                        <option value="Apparel & Accessory">Apparel & Accessory</option>
                        <option value="Home & Office">Home & Office</option>
                        <option value="Toy & Baby Stuff">Toy & Baby Stuff</option>
                        <option value="Health & Sports">Health & Sports</option>
                    </select>
                </div>
                <div class="form-group col-lg-6">
                    <label>Sells</label>
                    <input type="textbox" name="sells" class="form-control" id="" value="{!! $shops->sells !!}" placeholder="">
                </div>
                <div class="form-group col-lg-6">
                    <label>Base In</label>
                    <input type="textbox" name="location" class="form-control" id="" value="{!! $shops->location !!}" placeholder="location">
                </div>
                <div class="form-group col-lg-6">
                    <label>Payment Method</label>
                    <input type="textbox" name="payment" class="form-control" id="" value="{!! $shops->payment !!}" placeholder="example: paypal">
                </div>
                <div class="form-group col-lg-12">
                    <label>Description</label>
                    <textarea maxlength="600" class="form-control description"   id="message" name="description" placeholder="Description" rows="7">{!! $shops->description !!}</textarea>
                    <span class="help-block"><p id="characterLeft_editshop" class="help-block">You have reached the limit</p></span>
                </div>
                <button type="submit" class="btn btn-success btn-hover-green" id="edit_submit" style="width: 100%;"  >Make Changes</button>
                @endforeach
                {!! Form::close() !!}
            </div>
        </div>
    </div>
</div>

0 个答案:

没有答案