Skip to content
Browse files

better understandable control labels for list example

  • Loading branch information...
1 parent 566181e commit 1436477f5c05d352403cd6b4815c3439cadd0f56 @dodo committed May 17, 2012
Showing with 21 additions and 7 deletions.
  1. +16 −7 example/list.coffee
  2. +5 −0 example/list.html
View
23 example/list.coffee
@@ -9,19 +9,28 @@ jqueryify = (opts, tpl) ->
# the templates
-button = (tag, id, value) ->
- tag.$input class:'button', type:'button', id:id, value:value
+input = (tag, type, id, value, opts) ->
+ tag.$input(_.extend({class:type, name:id, type, id, value}, opts))
items = null # all our list entries
tplapi = new EventEmitter # every other event system should be suitable as well
list = jqueryify new Template schema:5, ->
@$div class:'controls', ->
- button this, "add", "add random entry"
- button this, "remove", "remove random entry"
- @$input class:'number', type:'number', id:'nmb', value:"0"
- @$input class:'text', type:'input', id:'text', placeholder:"try me!"
- button this, "insert", "insert"
+ input this, 'button', "add", "list.push(Math.random())",
+ title:"add to bottom"
+ input this, 'button', "remove", "list.shift()",
+ title:"remove from top"
+ @$br()
+ input this, 'button', "insert", "list.insert(i, text)",
+ title:"insert at position"
+ @span " where "
+ @$label for:'nmb', ->
+ @text " i="
+ input this, 'number','nmb', "0"
+ @$label for:'text', ->
+ @text " text="
+ input this, 'text', 'text', "", placeholder:"try me!"
@$ul class:'list', ->
items = new List
View
5 example/list.html
@@ -11,9 +11,14 @@
border:1px solid black;
}
+input[type="number"] {
+ width: 3em;
+}
+
</style>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
<script src="http://coffeescript.org/extras/coffee-script.js"></script>
+ <script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="../dt-list.browser.js"></script>
<script src="../dt-list.jquery.browser.js"></script>
<script src="../dt-jquery.browser.js"></script>

0 comments on commit 1436477

Please sign in to comment.
Something went wrong with that request. Please try again.