Bootbox jquery

时间:2016-03-25 10:17:19

标签: javascript jquery bootbox

您好我如何在bootbox jquery中调用函数?

这是一个例子,在 select name="Status"如果可能,我会调用一个函数来显示和隐藏tr tablehtml_form调用的function ChangeStatusDossier(UtenteCreatore) { var html_form = '<form name="ChangeStatusDossier" id="ChangeStatusDossier" class="ChangeStatusDossier"><table><tr><th colspan="2"><h2 class="blue">Change Dossier Status</h2></th></tr><tr><td><strong>Choose status </strong>&nbsp;&nbsp;</td><td><select name="Status" onchange="Show(this.value);"><option value="0">Under process</option><option value="1">Under collection</option><option value="2">Cargo collected</option><option value="159">In Warehouse</option><option value="1485">To Destination</option></select></td></tr><tr id ="HubChoose" style="display:none;"><td>Choose hub</td><td><select name="Hub"><option>HUB MILANO</option></select></td></tr><input type="hidden" name="UtenteCreatore" value="' + UtenteCreatore + '"></table><form>'; bootbox.confirm(html_form, function (result) { if (result) { $('#ChangeStatusDossier').submit(); } }); function Show(value) { if (value == "159") { $("#HubChoose").show(); } } } 。我该怎么做?

<script>
    //var searchInput ;//search için aramadaki değeri almaya çalışma

    $(document).ready(function TableData(searchInput) {
        var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return sParameterName[1] === undefined ? true : sParameterName[1];
                }
            }
        };

        //var searchInput = $("#inpSearch").val();//search için aramadaki değeri almaya çalışma
        var DocumentTypeId = getUrlParameter('DocumentTypeId');
        var Type = getUrlParameter('Type');
        //console.log("dokumantip: " + DocumentTypeId);
        //console.log("tip: " + Type);

        var datatable = null;
        $(document).ready(function () {
            $.extend(true, $.fn.dataTable.defaults, {
                "searching": false,
                "ordering": false
            });


            @*var dataSourceUrl = "@Url.Action(  Inbox ? "InboxList" : "OutboxList" ,"Folder")";*@
            @*var dataSourceUrl = "@Url.Action( Inbox ? "InboxListByType" : "OutboxList" ,"Folder")";*@

            if (Type == 1) {
                var dataSourceUrl = "@Url.Action( Inbox ? "ERPListByType" : "OutboxList" ,"Folder")";
            } else if (Type == 2) {
                var dataSourceUrl = "@Url.Action( Inbox ? "InboxListByType" : "OutboxList" ,"Folder")";
            } else if (Type == 3) {
                var dataSourceUrl = "@Url.Action( Inbox ? "OutboxListByType" : "OutboxList" ,"Folder")";
            } else if (Type == 4) {
                var dataSourceUrl = "@Url.Action( Inbox ? "DeletedDocumentsList" : "OutboxList" ,"Folder")";
            } else {
                //açılış ekranında default gelen kutusu e-TCGB gelsin
                var dataSourceUrl = "@Url.Action( Inbox ? "InboxListByType" : "OutboxList" ,"Folder", new { DocumentTypeID = 3 })";
            }

            if ($.fn.dataTable.isDataTable('#expandabledatatable')) {
                $('#expandabledatatable').dataTable().fnDestroy();
            }

            datatable = $('#expandabledatatable').dataTable({
                //"sDom": "Tflt<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>",
                //"processing": true,
                //info: false,

                serverSide: true,
                ajax: {
                    "url": dataSourceUrl,
                    "data": { DocumentTypeId: DocumentTypeId, searchInput: searchInput },
                    "type": "POST"
                },
                columns: [
                    {
                        "data": "Id",
                        "render": function (data, type, row) {
                            return "<label><input type='checkbox' value='" + data + "' name='chkGrid'><span class='text'></span></label>";
                        }
                    },
                    { "data": "@Html.Raw(Inbox ? "SenderCompany" : "ReceiverCompany")" },
                    { "data": "DocumentTypeName" },
                    {
                        "data": "RegistrationDate",
                        "render": function (data, type, row) {
                            return moment(parseInt(data.substr(6))).format('DD.MM.YYYY hh:mm');
                        }
                    },
                    {
                        "data": "RegistrationCode",
                        "render": function (data, type, row) {
                            console.log(row);
                            return "<a href='@Url.Action("View","Folder")/" + row["Id"] + "'>" + data + "</a>";
                        }
                    },
                    { "data": "CustomsTransportType" },
                    { "data": "VehicleIdNo" },
                    { "data": null, "defaultContent": "" },
                    { "data": "ConsignorName" },
                    { "data": "ConsigneeName" },
                    { "data": "TotalNoOfPackages" },
                    { "data": "TotalGrossWeight" }
                ],
                iDisplayLength: 10,
                language: {
                    "info": "Toplam kayıt : \_TOTAL\_<br/> Gösterilen : \_START\_ - \_END\_",
                    "paginate": {
                        "first": "İlk",
                        "last": "Son",
                        "next": "İleri",
                        "previous": "Geri"
                    }
                }
            });



        });
    });


    $(document).ready(function () {
        $('#btnSearch').click(function () {
            alert("test");
            TableData($('#inpSearch').val())
        })
    });



</script>

1 个答案:

答案 0 :(得分:0)

在您的情况下,最好使用dialog方法而不是confirm

以下是你如何做到这一点:

function ShowHub(value) {
  if (value == "159") {
    $("#HubChoose").show();
  }
  else {
    $("#HubChoose").hide();
  }
}

jQuery("#default").on("click", function() {
  bootbox.dialog({
    title: "This is a form in a modal.",
    message:
'<form class="ChangeStatusDossier" id="ChangeStatusDossier" name="ChangeStatusDossier">' +
    '<input name="UtenteCreatore" type="hidden" value="' + UtenteCreatore + '">' +
    '<table>' +
        '<tr>' +
            '<th colspan="2">' +
                '<h2 class="blue">Change Dossier Status</h2>' +
            '</th>' +
        '</tr>' +
        '<tr>' +
            '<td><strong>Choose status</strong> &nbsp;&nbsp;</td>' +
            '<td><select name="Status" onchange="ShowHub(this.value);">' +
                '<option value="0">' +
                    'Under process' +
                '</option>' +
                '<option value="1">' +
                    'Under collection' +
                '</option>' +
                '<option value="2">' +
                    'Cargo collected' +
                '</option>' +
                '<option value="159">' +
                    'In Warehouse' +
                '</option>' +
                '<option value="1485">' +
                    'To Destination' +
                '</option>' +
            '</select></td>' +
        '</tr>' +
        '<tr id="HubChoose" style="display:none;">' +
            '<td>Choose hub</td>' +
            '<td><select name="Hub">' +
                '<option>' +
                    'HUB MILANO' +
                '</option>' +
            '</select></td>' +
        '</tr>' +
    '</table>' +
'</form>',
    buttons: {
      success: {
        label: "Submit",
        className: "btn-success",
        callback: function () {
            $('#ChangeStatusDossier').submit();
          showResult("Form submitted!");
        }
      },
    cancel: {
      label: "Cancel",
      className: "btn-danger",
      callback: function() {
        showResult("Canceled!");
      }
    }
   } // buttons
  }); // dialog
});


function showResult(result) {
  if (typeof result !== "undefined" && result !== null) {
    console.log(result);
  }
}

这是一个有效的 DEMO