Commit 1f9c5afc authored by Akira Sudoh's avatar Akira Sudoh

IE11 fix for Dojo example, fixes #1349.

parent 80c34776
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<header id="header"> <header id="header">
<h1>todos</h1> <h1>todos</h1>
<form id="todo-form" data-dojo-attach-event="submit: addTodo"> <form id="todo-form" data-dojo-attach-event="submit: addTodo">
<input id="new-todo" placeholder="What needs to be done?" data-dojo-type="dojox/mvc/Element" data-dojo-props="_setDisabledAttr: 'domNode', value: at(this, 'newTodo'), disabled: at(this, 'saving')" autofocus> <input id="new-todo" placeholder="What needs to be done?" data-dojo-type="dojox/mvc/Element" data-dojo-mixins="todo/widgets/TodoEnter" data-dojo-props="_setDisabledAttr: 'domNode', value: at(this, 'newTodo'), disabled: at(this, 'saving')" autofocus>
</form> </form>
</header> </header>
<section id="main" data-dojo-type="dijit/_WidgetBase" data-dojo-props="_setHiddenAttr: '', hidden: at(this.get('todos'), 'length').transform(this.emptyConverter)"> <section id="main" data-dojo-type="dijit/_WidgetBase" data-dojo-props="_setHiddenAttr: '', hidden: at(this.get('todos'), 'length').transform(this.emptyConverter)">
......
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dijit/_WidgetBase'
], function (declare, lang, _WidgetBase) {
// To use Dojo's super call method, inherited()
/*jshint strict:false*/
var ENTER_KEY = 13;
/**
* Widget that emits `change` event when the element it is applied to gets an keydown event of enter key.
* Primary for IE which does not fire `change` event on `<input>` upon parent form's submission.
* @class TodoEnter
*/
return declare(_WidgetBase, {
postCreate: function () {
this.inherited(arguments);
this.on('keydown', lang.hitch(this, function (event) {
if (event.keyCode === ENTER_KEY) {
this.emit('change');
}
}));
}
});
});
...@@ -17,7 +17,8 @@ define([ ...@@ -17,7 +17,8 @@ define([
'../store/TodoLocalStorage', '../store/TodoLocalStorage',
'dojox/mvc/Element', 'dojox/mvc/Element',
'dojox/mvc/WidgetList', 'dojox/mvc/WidgetList',
'./CSSToggleWidget' './CSSToggleWidget',
'./TodoEnter'
], function (declare, ], function (declare,
array, array,
lang, lang,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment