Giter Site home page Giter Site logo

superload's Introduction

SuperLoad jQuery Plugin

This plugin adds the ability to update multiple elements with a single Ajax response.

Usage

$.superLoad( options );

The options are the same as taken by the jQuery.ajax( ) method, with the following observations:

  • dataType: defaults to 'html'
  • success: will be called after the content is updated on the page.

Expected response format:

	<div class="ajax-content" title="!update #div1">                                                              
		<p>                                                                                                       
			Anything inside this div will be used to update the #div1 element                                     
			like $('#div1').html( $(thisDiv).html() );                                                            
		</p>                                                                                                      
	</div>                                                                                                        
														   
	<div class="ajax-content" title="!appendTo #div2">                                                            
		<p>                                                                                                       
			Anything inside this div will be appended to the #div2 element                                        
			like $('#div2').append( $(thisDiv).html() );                                                          
		</p>                                                                                                      
	</div>                                                                                                        
														   
	<div class="ajax-content" title="!prependTo #div3">                                                           
		<p>                                                                                                       
			Anything inside this div will be prepended to the #div3 element                                       
			like $('#div3').prepend( $(thisDiv).html() );                                                         
		</p>                                                                                                      
	</div>                                                                                                        
														   
	<div class="ajax-content" title="#div4">                                                                      
		<p>                                                                                                       
			if the !command is not given, !update will be assumed                                                 
		</p>                                                                                                      
	</div>                                                                                                        
														   
	<div class="ajax-content" title="!replaceWith #div5">                                                         
		<p>                                                                                                       
			Replaces #div5 with this P element                                                                    
		</p>                                                                                                      
	</div>                                                                                                        
														   
	<script>                                                                                                      
		//each script tag will be evaluated after the content has been applied.                                   
		doStuff();                                                                                                
	</script>                                                                                                     
														   
	<script>                                                                                                      
		doOtherStuff();                                                                                           
	</script>                                                                                                     
														   
</div>                                                                                                            

The title attribute:

  • The ajax-content element's title attribute is used to determine what to do with the content:
  • The format is: "!command selector"
  • "!command": defaults to !update
  • !update: replaces the inner HTML of the selected element(s) with the inner HTML of the ajax-content
  • !prependTo: adds the inner HTML of the ajax-content to the top of the inner HTML of the selected element(s)
  • !appendTo: adds the inner HTML of the ajax-content to the bottom of the inner HTML of the selected element(s)
  • !other: Beyond the above 3 standard !commands, one can also simply pass the name of any valid jQuery command (default of from a plugin) as long as the command is able to be applied to the selected element(s) and takes the new content as its argument.

LICENSE:

Dual licensed under the MIT and GPL licenses:

superload's People

Contributors

sergiopereira avatar

Watchers

Imab Asghar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.