Skip to content

Commit 27a4af5

Browse files
Merge pull request #40 from mendix/feature/widget_context
Add widget context as an argument to the jQuery script
2 parents 6aa1762 + a333957 commit 27a4af5

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "HTMLSnippet",
3-
"version": "3.9.5",
3+
"version": "3.9.6",
44
"description": "",
55
"license": "",
66
"author": "",

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ define([
174174
(function (snippetCode) {
175175
/**
176176
* user's are get used to or might expect to have jQuery available globally
177-
* and they will write their code according to that, and since we, in this widget, don't expose
178-
* jQuery globally, we'll check user's code snippet if there is any attempt to access jQuery
179-
* from the global scope ( window ).
177+
* and they will write their code according to that, and since we, in this widget, don't expose
178+
* jQuery globally, we'll check user's code snippet if there is any attempt to access jQuery
179+
* from the global scope ( window ).
180180
*/
181181
var jqueryIdRegex1 = /window.\jQuery/g;
182182
var jqueryIdRegex2 = /window.\$/g;
@@ -188,7 +188,8 @@ define([
188188
"console.debug('your code snippet is evaluated and executed against JQuery version:'+ this.jquery.fn.jquery);";
189189
eval(snippetCode);
190190
}).call({
191-
jquery: jQuery // pass JQuery as the context of the immediate function which will wrap the code snippet
191+
jquery: jQuery, // pass JQuery as the context of the immediate function which will wrap the code snippet
192+
widget: this // pass the HTMLSnippet widget context itself, so the code could use listen/addOnDestroy
192193
}, this.contents); // pass the code snippet as an arg
193194
} catch (error) {
194195
this._handleError(error);

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="HTMLSnippet" version="3.9.5" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="HTMLSnippet" version="3.9.6" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="HTMLSnippet/HTMLSnippet.xml"/>
66
<widgetFile path="HTMLSnippet/HTMLSnippetContext.xml"/>

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const widgetVersion = package.version;
1919
filename: `${widgetName}/widget/[name].js`,
2020
chunkFilename: `${widgetName}/widget/${widgetName}[id].js`,
2121
libraryTarget: "amd",
22-
publicPath: "widgets/"
22+
publicPath: "/widgets/"
2323
},
2424
devtool: false,
2525
mode: "production",

0 commit comments

Comments
 (0)