|
20 | 20 | var defaults = { |
21 | 21 | loadingHtml: "Loading ...", |
22 | 22 | ajaxHttpMethod: "GET", |
| 23 | + dataType: "HTML", |
23 | 24 | ajaxContainerReady: "ajax-container-ready" |
24 | 25 | }; |
25 | 26 |
|
|
38 | 39 | var actionScope = $(this).attr("actionScope") ? $(this).attr("actionScope") : "html"; |
39 | 40 | if (actionType === "ajax-model") { |
40 | 41 | var href = $(this).attr("href") ? $(this).attr("href") : $(this).attr("actionLink"); |
41 | | - $this.fetchAjaxContentByModal(href); |
| 42 | + BootstrapModalWrapperFactory.createAjaxModal({ |
| 43 | + message: $this.options.loadingHtml, |
| 44 | + dataType: $this.options.dataType, |
| 45 | + httpMethod: $this.options.ajaxHttpMethod, |
| 46 | + ajaxContainerReadyEventName: $this.options.ajaxContainerReady, |
| 47 | + url: href |
| 48 | + }); |
42 | 49 | } else if (actionType === "action-ref") { |
43 | 50 | var actionRefName = $(this).attr("action-ref-by-name") ? $(this).attr("action-ref-by-name") : ""; |
44 | 51 | if ($(actionScope + " [action-name='" + actionRefName + "']").length > 0) |
|
59 | 66 | } |
60 | 67 | }); |
61 | 68 | }; |
62 | | - |
63 | | - BootstrapActionable.prototype.fetchAjaxContentByModal = function (remoteUrl, passData) { |
64 | | - var $this = this; |
65 | | - var ajaxModalContainer = BootstrapModalWrapperFactory.createModal({ |
66 | | - message: $this.options.loadingHtml, |
67 | | - closable: false, |
68 | | - closeByBackdrop: false, |
69 | | - closeByKeyboard: false |
70 | | - }); |
71 | | - ajaxModalContainer.originalModal.removeClass("fade"); |
72 | | - ajaxModalContainer.originalModal.find(".modal-dialog").css({transition: 'all .3s'}); |
73 | | - |
74 | | - ajaxModalContainer.show(); |
75 | | - |
76 | | - if (passData === undefined) { |
77 | | - passData = {}; |
78 | | - } |
79 | | - |
80 | | - passData["ajaxModalId"] = ajaxModalContainer.options.id; |
81 | | - |
82 | | - $.ajax({ |
83 | | - type: $this.options.ajaxHttpMethod, |
84 | | - dataType: "html", |
85 | | - url: remoteUrl, |
86 | | - data: {}, |
87 | | - success: function (response, textStatus, jqXHR) { |
88 | | - // make sure the modal dialog is open before update |
89 | | - // its body with ajax response and triggering javaTmpAjaxContainerReady event. |
90 | | - var timeOut = 700; |
91 | | - function runWhenDialogOpen() { |
92 | | -// console.log("time out [" + Math.round(timeOut / 2) + "], isOpen [" + ajaxModalContainer.isOpen + "], is show [" + ajaxModalContainer.originalModal.hasClass("show") + "]"); |
93 | | - if (ajaxModalContainer.isOpen) { |
94 | | - ajaxModalContainer.updateSize("modal-lg"); |
95 | | - setTimeout(function () { |
96 | | - ajaxModalContainer.updateMessage(response); |
97 | | - setTimeout(function () { |
98 | | - $("#" + ajaxModalContainer.options.id).trigger($this.options.ajaxContainerReady, [ajaxModalContainer]); |
99 | | - }, 0); |
100 | | - }, 350); |
101 | | - } else { |
102 | | - timeOut = timeOut <= 50 ? 50 : Math.round(timeOut / 2); |
103 | | - setTimeout(runWhenDialogOpen, timeOut); |
104 | | - |
105 | | - } |
106 | | - } |
107 | | - runWhenDialogOpen(); |
108 | | - } |
109 | | - }); |
110 | | - }; |
111 | | - |
112 | 69 | return new BootstrapActionable(); |
113 | 70 | })); |
0 commit comments