Skip to content

Commit 5f3873c

Browse files
AurelioDeRosaarthurvr
authored andcommitted
plugins/advanced-plugin-concepts: clarify best-practice
Fixes jquerygh-513 Closes jquerygh-526
1 parent fa001a6 commit 5f3873c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

page/plugins/advanced-plugin-concepts.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,14 @@ A bad implementation:
240240

241241
```
242242
// Plugin code
243-
$( "<div id=\"the-gallery-wrapper\" />").appendTo( "body" );
243+
$( "<div class='gallery-wrapper' />" ).appendTo( "body" );
244244
245-
$( "#the-gallery-wrapper" ).append( "..." );
245+
$( ".gallery-wrapper" ).append( "..." );
246+
```
247+
248+
To allow users to access and even manipulate those information, you can store them in a variable containing the settings of your plugin. A better implementation of the previous code is shown below:
246249

250+
```
247251
// Retain an internal reference:
248252
var wrapper = $( "<div />" )
249253
.attr( settings.wrapperAttrs )
@@ -258,7 +262,7 @@ Notice that we've created a reference to the injected wrapper and we're also cal
258262
```
259263
var defaults = {
260264
wrapperAttrs : {
261-
id: "gallery-wrapper"
265+
class: "gallery-wrapper"
262266
},
263267
// ... rest of settings ...
264268
};

0 commit comments

Comments
 (0)