Files
old-web/app/views/realEstateType.ejs
2019-10-21 10:08:12 +02:00

74 lines
2.1 KiB
Plaintext

<br><br>
<form method="POST" id="form-real-estate-type">
<div class="center-align">
<div class="row">
<select class="segment-select">
<option value="1">Prodaja</option>
<option value="2" disabled>Najam (uskoro)</option>
</select>
</div>
<br>
<div class="collection">
<% for(const realEstateType of realEstateTypes) { %>
<a class="waves-effect row collection-item"
id="<%= realEstateType.id %>"
href="#"
style="color: #02adba"
onclick="saveAndSubmit(this.id)"
>
<span class="center-align"><%= realEstateType.title %></span>
</a>
<% } %>
</div>
<input type="hidden" name="realEstateType" id="realEstateType" />
</div>
</form>
<script>
(function($) {
$.fn.extend({
Segment: function() {
$(this).each(function() {
const wrapper = $("<div>", { class: "ui-segment" });
$(this)
.find("option")
.each(function(param, param2) {
const isDisabled = $(param2).attr("disabled");
const option = $("<span>", {
class: "option",
text: $(this).text(),
value: $(this).val(),
disabled: isDisabled
});
if ($(this).is(":selected")) {
option.addClass("active");
}
wrapper.append(option);
});
$(this).after(wrapper);
$(this).hide();
});
}
});
})(jQuery);
$(document).ready(() => {
$(".segment-select").Segment();
});
function saveAndSubmit(id) {
$("#realEstateType").val(id);
$("#form-real-estate-type").submit();
}
</script>