You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+123Lines changed: 123 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,129 @@ cd bootstrap-actionable
14
14
npm install
15
15
gulp
16
16
```
17
+
## Tutorial
18
+
[Bootstrap Actionable plugin](https://github.com/JavaTMP/bootstrap-actionable) is a small Javascript code that help us implement
19
+
click actions for `<a>` and `<button>` tags by declarative way and provide functionalities to load AJAX content in Bootstrap Modal
20
+
Wrapper instance. The following are the main action types provided by the plugin:
17
21
22
+
### `"action-ref-href"` Action Type
23
+
24
+
This is the simplest function of the plugin which fires other link's `click` event that contains the value of `href`'s attribute equal to provided one. We use this type on sidebar small shortcut `buttons` and on all `home.html`'s `buttons`. See the following button tags html code:
25
+
```
26
+
<button class="btn btn-primary"
27
+
actionType="action-ref-href"
28
+
action-ref-by-href="pages/home.html">
29
+
<i class="fa fa-home fa-fw"></i>
30
+
</button>
31
+
```
32
+
Pressing the above button will make actionable code search for link with value `"pages/home.html"` in its `href` attribute and then fire a `click` event on it.
33
+
34
+
Another button code example from `home.html` page:
Pressing the above button will make actionable code search for link value `"pages/custom-pages/login-pages/default-login-page.html"` in its `href` attribute in `.sidebar` div only as we explicitly set the `actionScope` attribute and because the link on sidebar contains target attribute the actionable plugin code will use `window.open` to open it. See the following code for target link in the sidebar:
It is similar to `"action-ref-href"` but instead of using URL to search for value of `href` attribute, it uses an alias name to search for. See the following code for `"Compose Message"` and `"View Message"` sidebar link in `index.html` page:
And see the following tags from `./web/pages/custom-pages/inbox/inbox-messages.html` file:
69
+
```
70
+
<button
71
+
type="button"
72
+
actionType="action-ref"
73
+
action-ref-by-name="compose-page"
74
+
class="btn btn-danger btn-block actionable">
75
+
Compose
76
+
</button>
77
+
<a
78
+
actionType="action-ref"
79
+
action-ref-by-name="view-message"
80
+
alt=""
81
+
href="">
82
+
Customer Support
83
+
</a>
84
+
```
85
+
86
+
### `"ajax-request-in-model"` action type
87
+
This action type is very powerful and it fires an AJAX request using href URL and load its contents in [Bootstrap Modal Wrapper](/pages/javatmp-bootstrap-modal-wrapper"JavaTMP Bootstrap Modal Wrapper Plugin") instance and give the control to the modal. Example links are the message links in dropdown menu items in main navbar in `index.html` page:
The following HTML code is the response of above AJAX request:
112
+
```
113
+
<div class="dynamic-ajax-content">
114
+
...
115
+
<script type="text/javascript">
116
+
jQuery(function ($) {
117
+
118
+
// here we can reference the container bootstrap modal by its id
119
+
// passed as parameter to request by name "ajaxModalId"
120
+
// or for demo purposese ONLY we can get a reference top modal
121
+
// in current open managed instances in BootstrapModalWrapperFactory
122
+
var currentParentModal = BootstrapModalWrapperFactory.globalModals\[BootstrapModalWrapperFactory.globalModals.length - 1\];
123
+
124
+
$("#" + currentParentModal.options.id).on(javatmp.settings.javaTmpAjaxContainerReady, function (event, modal) {
125
+
modal.updateSize("modal-lg");
126
+
modal.updateTitle("View Message");
127
+
modal.updateClosable(true);
128
+
modal.addButton({
129
+
label: "Close",
130
+
cssClass: "btn btn-primary",
131
+
action: function (modalWrapper, button, buttonData, originalEvent) {
132
+
return modalWrapper.hide();
133
+
}
134
+
});
135
+
});
136
+
});
137
+
</script>
138
+
</div>
139
+
```
140
+
S
18
141
## Copyright and License
19
142
bootstrap-actionable is copyrighted by [JavaTMP](http://www.javatmp.com) and licensed under [MIT license](https://github.com/JavaTMP/bootstrap-actionable/blob/master/LICENSE).
0 commit comments