Commit 90bf2510 authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Add simple string field.

parent c69b64e0
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Stringfield</title>
<!-- renderjs -->
<script src="../lib/rsvp.min.js"></script>
<script src="../lib/renderjs.min.js"></script>
<!-- custom script -->
<script src="stringfield.js" type="text/javascript"></script>
</head>
<body>
<input type='text' data-mini="true" />
</body>
</html>
/*global window, rJS, RSVP */
(function(window, rJS, RSVP) {
"use strict";
rJS(window).ready(function(gadget) {
return gadget.getElement().push(function(element) {
gadget.element = element;
});
}).declareMethod("render", function(options) {
var input = this.element.querySelector("input"), field_json = options.field_json || {};
input.setAttribute("value", field_json.value || "");
input.setAttribute("name", field_json.key);
input.setAttribute("title", field_json.title);
}).declareMethod("getContent", function() {
var input = this.element.querySelector("input"), result = {};
result[input.getAttribute("name")] = input.value;
return result;
});
})(window, rJS, RSVP);
\ No newline at end of file
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