Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#input_form_container").loadActionTemplate()
- .find ('.form-focus:first').focus();
- <input class="span1 form-focus" id="min-duration" name="min-duration" size="16" type="text">
- $.fn.extend({
- // loadActionTemplate plugin
- loadActionTemplate: function(options) {
- //default settings
- var defaults = {
- actionDOM : '#do_something_dropdown',
- cache : true
- }
- // store the "this" state for safe keeping
- var domElements = $(this);
- // merge user options into default
- var options = $.extend(defaults, options);
- // assign the "action" to an easily addressible variable
- var action = $(options.actionDOM).val();
- // get the HTML form template for this action
- LG_ServiceCall ( 'get-action-template' , {'action' : action} , function( r ) {
- var res = JSON.parse ( r );
- var template = res.results.template;
- // iterate through all matched DOM instances
- return domElements.each(function() {
- // get handle on DOM object operating on
- var element = $(this);
- element.html( template );
- element.find('.form-focus:first').focus();
- })
- });
- return domElements; // allows the function to operate in a chain
- }
- });
- function LG_ServiceCall( $service , $options , $callback );
- requestObj.success = function (r) {
- console.log ("Successful AJAX Call ( " + JSON.stringify (r) + ")");
- callback (r);
- }
Add Comment
Please, Sign In to add comment