<form id="form">
	<div>
		<input type="text" list="users" name="to" autocomplete="off" class="fill-width" placeholder="To"/>
	</div>
	<div>
		<textarea name="message" class="fill-width" placeholder="Message"/></textarea>
	</div>
	<div>
		<button value="Cancel" class="danger">Cancel</button>
		<button value="Create" onclick="$(this).parent().submit();">Create</button>
	</div>
	<datalist id="users">
		{{#each users}}
			<option value="{{name}}">
		{{/each}}
	</datalist>
</form>
<script>
	$(document).ready(function(){
		$('form#form').submit(function(){
			var data = $(this).serializeObject(),
				State = History.getState();
			for(var i in State.data){
				data[i] = State.data;
			}
			data.type = 'action';
			data.id = 'message';
			apiCall(data,function(d){
				if(!d.error){
					back();
				}else{
					$('#loading').hide();
				}
				return false;
			});
			return false;
		}).find('.danger').click(function(){
			back();
			return false;
		});
	});
</script>