Skip to content

Instantly share code, notes, and snippets.

@felds
Created September 25, 2012 21:39
Show Gist options
  • Select an option

  • Save felds/3784624 to your computer and use it in GitHub Desktop.

Select an option

Save felds/3784624 to your computer and use it in GitHub Desktop.
Exemplo de uso do ICanHaz
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Teste icanhaz</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<!-- cabeçalho -->
<div class="hero-unit">
<h1>Exemplo ICanHaz</h1>
</div>
<!-- .hero-unit -->
<!-- container dos novos formulários -->
<form action="" method="post" id="container-form">
<button type="button" class="btn add-form">Adicionar formulário</button>
</form>
</div>
<!-- .content -->
<!-- template dos novos formulários -->
<script id="user" type="text/html">
<div>
<label>Nome</label>
<input type="text" class="text" value="" name="" />
</div>
</script>
<!-- dependências -->
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="https://github.com/andyet/ICanHaz.js/raw/master/ICanHaz.min.js" type="text/javascript"></script>
<!-- o código que faz a mágica acontecer -->
<script type="text/javascript">
jQuery(function ($) {
$('.add-form').click(function () {
var user = ich.user();
user.appendTo('#container-form');
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment