没有显示Ajax的Bootstrap模式

时间:2015-07-07 13:47:09

标签: jquery ajax twitter-bootstrap laravel

使用带有Ajax的引导模式添加用户,但点击链接时屏幕会变暗但模态本身不会显示,而在网络private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("list", VirtualFilePermission[].class) }; 功能预览中,表单显示向上,所以控制器工作。

enter image description here

表单显示在html(控制台)中的' add'同样,但据说在错误的地方。

enter image description here

点击此链接时:

invite

它应该触发:

的JavaScript

<a>
<span class="sidebar-text">{{ trans('common.projects') }}
    ({{ count($projectsNav) }})</span> <span class="  pull-right">  <i
            href="/user/invite"
            class="fa fa-cog nopadding" data-toggle="modal"
            data-target="#modal-basic"
            style="padding: none !important;"></i>
</span>
</a>

路线

// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
    e.preventDefault();
    var url = $(this).attr('href');
    if (url.indexOf('#') == 0) {
        $(url).modal('open');
    } else {
        $.ajax({
            url: "/user/invite",
            headers: AjaxHeader,
            method: "POST",

            success: function (response) {
                $('<div class="modal hide fade">' + response + '</div>').modal();
            }
        });
       /* $.post(url, function(data) {
            $('<div class="modal hide fade">' + data + '</div>').modal();
        }).success(function() { $('input:text:visible:first').focus(); });*/
    }

控制器

Route::post('user/invite', 'UserController@showInvite');

刀片/模态表格

public function showInvite(UserTypeController $userType)
{
    $usertypes = $userType->getUsertypes();

    return view('user.invite', compact('usertypes'));
}

2 个答案:

答案 0 :(得分:0)

您需要将模态加载到您的html中。 解决方案是: 步骤1 将div模态容器直接手动添加到您想要添加模式的html中。 &lt; div class =“modal hide fade”&gt;&lt; / div&gt; 第2步 将模态加载到先前创建的容器中: $('[data-toggle =“modal”]')。click(function(e){     e.preventDefault();     //获取部分视图以模态显示     var $ modal = $('。modal');     $ modal.load('/ user / invite',function(){}); //这会将返回的html加载到您的模态容器中     $ modal.modal( '秀'); //显示模态 } UPDATE 从响应中删除外部模式div,因为您有2个根.modal容器。

答案 1 :(得分:0)

更改

Private Sub CommandButton3_Click()

Dim dateCheck As String
Dim lastRow As Long
Dim L As Integer
Dim I As Long
Dim shipDay As Date
Dim search As String
Dim usaTotal As Long
Dim usaCredit As Long
Dim usaDebit As Long

dateCheck = InputBox("What Date is Ship Day 1?", "Ship Day Entry")

If IsDate(dateCheck) Then
    shipDay = DateValue(dateCheck)
Else:
    MsgBox ("Invalid Date")
    Exit Sub
End If ' Prompts user for ship day 1, and checks if actual date

For L = 0 To 30  ' Execute this code for 1 month worth of dates

    shipDay = shipDay + L

    MsgBox shipDay

    For I = 1 To 10000  ' Check every row of the worksheet

        search = Worksheets("sheet1").Cells(I, 12).Value  ' Variable to use InStr to check for "CAN"


        If ((InStr(1, search, "CAN", vbBinaryCompare) = 0) _
            And (Worksheets("Sheet1").Cells(I, 8) = shipDay) _
            And (Worksheets("Sheet1").Cells(I, 6).Text = "Invoice")) Then

            usaDebit = Worksheets("Sheet1").Cells(I, 22).Value ' Account for   Debits
            usaCredit = Worksheets("Sheet1").Cells(I, 24).Value ' Account  for Credits
            usaTotal = usaTotal + usaCredit - usaDebit  ' Calculate contribution

            ' This is where I tried placing an Else: Next I, which gives me an else without for prompts.

        End If

    Next I

MsgBox (usaTotal)
Worksheets("JUNE canada").Cells(L + 10, 4).Value = usaTotal / 1000  'Enter value into sheet
usaTotal = 0    ' Reset usaTotal value

Next L

success: function (response) {
    $('<div class="modal hide fade">' + response + '</div>').modal();
}

cc:见Mivaweb的回答