Guest User

Untitled

a guest
Jan 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. $("#input_form_container").loadActionTemplate()
  2. .find ('.form-focus:first').focus();
  3.  
  4. <input class="span1 form-focus" id="min-duration" name="min-duration" size="16" type="text">
  5.  
  6. $.fn.extend({
  7. // loadActionTemplate plugin
  8. loadActionTemplate: function(options) {
  9. //default settings
  10. var defaults = {
  11. actionDOM : '#do_something_dropdown',
  12. cache : true
  13. }
  14. // store the "this" state for safe keeping
  15. var domElements = $(this);
  16. // merge user options into default
  17. var options = $.extend(defaults, options);
  18. // assign the "action" to an easily addressible variable
  19. var action = $(options.actionDOM).val();
  20. // get the HTML form template for this action
  21. LG_ServiceCall ( 'get-action-template' , {'action' : action} , function( r ) {
  22. var res = JSON.parse ( r );
  23. var template = res.results.template;
  24. // iterate through all matched DOM instances
  25. return domElements.each(function() {
  26. // get handle on DOM object operating on
  27. var element = $(this);
  28. element.html( template );
  29. element.find('.form-focus:first').focus();
  30. })
  31. });
  32. return domElements; // allows the function to operate in a chain
  33. }
  34. });
  35.  
  36. function LG_ServiceCall( $service , $options , $callback );
  37.  
  38. requestObj.success = function (r) {
  39. console.log ("Successful AJAX Call ( " + JSON.stringify (r) + ")");
  40. callback (r);
  41. }
Add Comment
Please, Sign In to add comment