Last active
August 29, 2015 13:57
-
-
Save bsara/9796979 to your computer and use it in GitHub Desktop.
An extended version of the Ember.TextArea component. Extended features include: onClick Actions, and auto focus on page load.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>Ember.js - Extended Text Area</title> | |
<script type='text/javascript' src="http://code.jquery.com/jquery-2.0.3.min.js"></script> | |
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.2.1/handlebars.min.js"></script> | |
<script type='text/javascript' src="http://builds.emberjs.com.s3.amazonaws.com/tags/v1.4.0/ember.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="http://necolas.github.io/normalize.css/3.0.0/normalize.css"> | |
<style type='text/css'> | |
body { | |
margin: 20px | |
} | |
div { | |
margin-bottom: 50px | |
} | |
</style> | |
<script type='text/javascript'> | |
//<![CDATA[ | |
window.onload=function(){ | |
var App = Ember.Application.create(); | |
App.InputTextareaComponent = Ember.TextArea.extend({ | |
becomeFocused: (function() { | |
var doFocus; | |
doFocus = this.get("doFocus"); | |
if ((doFocus !== null ? doFocus.trim() : void 0) === "true") { | |
return this.$().focus(); | |
} | |
}).on("didInsertElement"), | |
click: function() { | |
var clickAction; | |
clickAction = this.get("clickAction"); | |
if (clickAction !== null ? clickAction.trim() : void 0) { | |
// NOTE: To get the action to execute, use the commented code on the next line. | |
// this.sendAction("clickAction") | |
return alert("Action sent: " + clickAction); | |
} | |
} | |
}); | |
} | |
//]]> | |
</script> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<div> | |
<h2>Ember.js - Clickable Text Area</h2> | |
{{input-textarea clickAction="myAction" doFocus="true" placeholder="Click Me!!!"}} | |
</div> | |
<div> | |
<h2>Ember.js - Auto Focus Text Area</h2> | |
{{input-textarea doFocus="true" placeholder="Focus here on load"}} | |
</div> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment