added support for dynamically added inputs

This commit is contained in:
Federico Zivolo 2014-09-23 10:28:01 +02:00
parent f76e82f78b
commit 87a3791071

View File

@ -4,32 +4,37 @@ $(function (){
ripples.init(".btn:not(.btn-link), .navbar a, .nav-tabs a, .withripple");
// Add fake-checkbox to material checkboxes
$(".checkbox > label > input").after("<span class=check></span>");
$(document).bind("DOMSubtreeModified", function(){
// Add fake-checkbox to material checkboxes
$(".checkbox > label > input").not(".bs-material").addClass("bs-material").after("<span class=check></span>");
// Add fake-radio to material radios
$(".radio > label > input").after("<span class=circle></span><span class=check></span>");
// Add fake-radio to material radios
$(".radio > label > input").not(".bs-material").addClass("bs-material").after("<span class=circle></span><span class=check></span>");
// Add elements for material inputs
$("input.form-control, textarea.form-control, select.form-control").each( function() {
$(this).wrap("<div class=form-control-wrapper></div>");
$(this).after("<span class=material-input></span>");
if ($(this).hasClass("floating-label")) {
var placeholder = $(this).attr("placeholder");
$(this).attr("placeholder", null).removeClass("floating-label");
$(this).after("<div class=floating-label>" + placeholder + "</div>");
}
if ($(this).is(":empty") || $(this).val() === null || $(this).val() == "undefined" || $(this).val() === "") {
$(this).addClass("empty");
}
// Add elements for material inputs
$("input.form-control, textarea.form-control, select.form-control").not(".bs-material").each( function() {
$(this).addClass("bs-material");
$(this).wrap("<div class=form-control-wrapper></div>");
$(this).after("<span class=material-input></span>");
if ($(this).hasClass("floating-label")) {
var placeholder = $(this).attr("placeholder");
$(this).attr("placeholder", null).removeClass("floating-label");
$(this).after("<div class=floating-label>" + placeholder + "</div>");
}
if ($(this).is(":empty") || $(this).val() === null || $(this).val() == "undefined" || $(this).val() === "") {
$(this).addClass("empty");
}
if ($(this).parent().next().is("[type=file]")) {
$(this).parent().addClass("fileinput");
var $input = $(this).parent().next().detach();
$(this).after($input);
}
});
if ($(this).parent().next().is("[type=file]")) {
$(this).parent().addClass("fileinput");
var $input = $(this).parent().next().detach();
$(this).after($input);
}
});
$(document).on("keyup change", ".form-control", function() {
var self = $(this);
setTimeout(function() {