newmessage.template 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <form id="form">
  2. <div>
  3. <input type="text" list="users" name="to" autocomplete="off" class="fill-width" placeholder="To"/>
  4. </div>
  5. <div>
  6. <textarea name="message" class="fill-width" placeholder="Message"/></textarea>
  7. </div>
  8. <div>
  9. <button value="Cancel" class="danger">Cancel</button>
  10. <button value="Create" onclick="$(this).parent().submit();">Create</button>
  11. </div>
  12. <datalist id="users">
  13. {{#each users}}
  14. <option value="{{name}}">
  15. {{/each}}
  16. </datalist>
  17. </form>
  18. <script>
  19. $(document).ready(function(){
  20. $('form#form').submit(function(){
  21. var data = $(this).serializeObject(),
  22. State = History.getState();
  23. for(var i in State.data){
  24. data[i] = State.data;
  25. }
  26. data.type = 'action';
  27. data.id = 'message';
  28. apiCall(data,function(d){
  29. if(!d.error){
  30. back();
  31. }else{
  32. $('#loading').hide();
  33. }
  34. return false;
  35. });
  36. return false;
  37. }).find('.danger').click(function(){
  38. back();
  39. return false;
  40. });
  41. });
  42. </script>