$(document).ready(function(){ var isMobile = true; isMobile = true; renderSelect('select.stdlist'); // console.log("isMobile:", isMobile); }); function renderSelect(s) { $('body').find(s).each(function(i){ if ($(this).hasClass('renderTrue')) return; var select = $(this); var el = $('
', { class:'selectRender custom-select form-control-lg fvalid', html: select.find('option:selected').html() }); select.on({ 'change' : function() { //console.log(el.html(), '=>', select.find('option:selected').html(), select.val()); el.html(beati(select.find('option:selected').text())); }}); el.bind('click',function() { //$('#selectModal .modal-title').html(select.attr("info")); $("#selectModal .modal-body").html(' '); select.find('option').each(function(index, element){ var option = $(this); var o = $('
',{ class: 'item', html: beati(option.text()) }); o.attr('index', index); o.attr('days', option.attr('ile')); o.attr('groupdays', option.attr('groupdays')); o.attr('tag', option.attr('tag')); if (select.prop('selectedIndex') == index) { o.addClass("item-selected"); } o.on({ 'click' : function() { //console.log('click'); $(".item").removeClass("item-selected"); $(this).addClass("item-selected"); $('#selectModal').modal('toggle'); el.html(beati(o.html())); select.prop('selectedIndex', index); select.change(); select.click(); //console.log(index, select.val()); }}); $("#selectModal .modal-body").append(o); }); $('#selectModal').modal(); if (select.attr("id") == "fRodzajZezwolenia") { $("#smFiltr").css("display", "block"); setOkresoweRoczne("okresowe"); ukryjTags(); } else { $("#smFiltr").css("display", "none"); } }); $(this).addClass('renderTrue'); select.hide().after(el); }); } function beati(str) { var res = str.split(" - "); if (res.length > 1) { res[0] = '' + res[0] + ''; res[1] = '' + res[1] + ''; res = res.join(" - "); } else { res = str; } return res; }