Skip to content

Commit

Permalink
textbox fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ChapelR committed Jan 25, 2020
1 parent 4fbb798 commit b5eb775
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ dist

# TernJS port file
.tern-port
*.zip
*.zip
test/
10 changes: 5 additions & 5 deletions examples/textbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
// textbox input macro for Harlowe
'use strict';

// set up change event handler
$(document).on('change.textbox-macro.macro', 'input[data-var]', function () {
Harlowe.variable($(this).attr('data-var').trim(), $(this).val() || '');
});

Harlowe.macro('textbox', function (varName, placeholder) {
// handle errors
var err = this.typeCheck([
Expand All @@ -25,11 +30,6 @@
// throw
if (err) throw err;

// set up change event handler
$(document).on('change.textbox-macro', 'input[data-var="' + varName + '"]', function () {
Harlowe.variable(varName, $(this).val() || '');
});

// return html structure
return '<input placeholder="' + (placeholder || '') + '" type="text" data-var="' + varName + '">';
});
Expand Down

0 comments on commit b5eb775

Please sign in to comment.