Skip to content

Instantly share code, notes, and snippets.

@eagostini
Last active November 30, 2017 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eagostini/6ee686ea81e2c76720347225c0a23af6 to your computer and use it in GitHub Desktop.
Save eagostini/6ee686ea81e2c76720347225c0a23af6 to your computer and use it in GitHub Desktop.
jQuery Hanging
<!DOCTYPE html>
<html>
<head>
<!-- jQuery Hanging Dependencies -->
<script src="https://unpkg.com/jquery/dist/jquery.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-boot/dist/jquery-boot.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-dirty/dist/jquery-dirty.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-namely/dist/jquery-namely.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-search/dist/jquery-search.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/jquery-hanging/dist/jquery-hanging.min.js" type="text/javascript"></script>
</head>
<body>
<h1>Want to see it live?</h1>
<hr />
<p>Check the example out at <a href="https://eagostini.github.io/jquery-hanging">jQuery Hanging</a>.</p>
<p>To see its <strong>HTML</strong> implementation I recomend you using your favorite browser inspector.</p>
<p>For the sake of space I will not display it here.</p>
</body>
</html>
/**
* What should I say?
*
* I am selecting the `send` button in the page. I am using **jQuery Namely**
* extension to make it easier to select elements by the name attribute. You
* don't need to use it but just know that it's a dependency and must be
* available anyway.
*
* Then I call the `hangs` method (provided by **jQuery Hanging**) informing the
* target (as a selector but it could be an **HTML** element or a **jQuery**
* object as well).
*
* Thanks to **jQuery Validation** plugin we can trust that our button will be
* enabled only when the given target is valid.
*
* @see {@link https://github.com/eagostini/jquery-hanging|jQuery Hanging}
* @see {@link https://github.com/eagostini/jquery-namely|jQuery Namely}
* @see {@link https://jqueryvalidation.org|jQuery Validation}
*/
jQuery(function ($) {
$('@send').hangs('form.box');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment