Skip to content

Commit 1b5b277

Browse files
authored
Merge pull request #1151 from adumesny/develop
added info on how to extend library
2 parents 3211512 + ee53a17 commit 1b5b277

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Join us on Slack: https://gridstackjs.troolee.com
2727
- [Basic usage](#basic-usage)
2828
- [Requirements](#requirements)
2929
- [API Documentation](#api-documentation)
30+
- [Extend Library](#extend-library)
3031
- [Touch devices support](#touch-devices-support)
3132
- [gridstack.js for specific frameworks](#gridstackjs-for-specific-frameworks)
3233
- [Change grid columns](#change-grid-columns)
@@ -127,6 +128,24 @@ Using gridstack.js with jQuery UI
127128
Documentation can be found [here](https://github.com/gridstack/gridstack.js/tree/develop/doc).
128129

129130

131+
## Extend Library
132+
133+
You can easily extend or patch gridstack with code like this:
134+
135+
```javascript
136+
$(function () {
137+
// extend gridstack with our own custom method
138+
window.GridStackUI.prototype.printCount = function() {
139+
console.log('grid has ' + this.grid.nodes.length + ' items');
140+
};
141+
142+
$('.grid-stack').gridstack();
143+
144+
// you can now call on any grid this...
145+
$('.grid-stack').data('gridstack').printCount();
146+
});
147+
```
148+
130149
## Touch devices support
131150

132151
Please use [jQuery UI Touch Punch](https://github.com/furf/jquery-ui-touch-punch) to make jQuery UI Draggable/Resizable

demo/two.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
1212

1313
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
14-
<!--
15-
16-
<script src="https://cdn.jsdelivr.net/npm/gridstack@0.6.3/dist/gridstack.js"></script>
17-
<script src="https://cdn.jsdelivr.net/npm/gridstack@0.6.3/dist/jquery-ui.js"></script>
18-
<script src="https://cdn.jsdelivr.net/npm/gridstack@0.6.3/dist/gridstack.jQueryUI.js"></script>
19-
-->
20-
2114
<script src="../dist/jquery-ui.min.js"></script>
2215
<script src="../src/gridstack.js"></script>
2316
<script src="../src/gridstack.jQueryUI.js"></script>

0 commit comments

Comments
 (0)