implement Rent option on the frontend
This commit is contained in:
@@ -3,9 +3,17 @@
|
||||
<div class="center-align">
|
||||
|
||||
<div class="row">
|
||||
<select class="segment-select">
|
||||
<option value="1">Prodaja</option>
|
||||
<option value="2" disabled>Najam (uskoro)</option>
|
||||
<select class="segment-select" id="adType" name="adType">
|
||||
<option value="<%= AD_TYPE.AD_TYPE_SALE.id %>"
|
||||
<% if (selectedAdType === AD_TYPE.AD_TYPE_SALE.id) { %>
|
||||
selected="selected"
|
||||
<% } %>
|
||||
><%= AD_TYPE.AD_TYPE_SALE.title %></option>
|
||||
<option value="<%= AD_TYPE.AD_TYPE_RENT.id %>"
|
||||
<% if (selectedAdType === AD_TYPE.AD_TYPE_RENT.id) { %>
|
||||
selected="selected"
|
||||
<% } %>
|
||||
><%= AD_TYPE.AD_TYPE_RENT.title %></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -33,16 +41,17 @@
|
||||
$.fn.extend({
|
||||
Segment: function() {
|
||||
$(this).each(function() {
|
||||
const self = $(this);
|
||||
const onchange = self.attr('onchange');
|
||||
const wrapper = $("<div>", { class: "ui-segment" });
|
||||
$(this)
|
||||
.find("option")
|
||||
.each(function(param, param2) {
|
||||
const isDisabled = $(param2).attr("disabled");
|
||||
.each(function() {
|
||||
const option = $("<span>", {
|
||||
class: "option",
|
||||
onclick: onchange,
|
||||
text: $(this).text(),
|
||||
value: $(this).val(),
|
||||
disabled: isDisabled
|
||||
});
|
||||
if ($(this).is(":selected")) {
|
||||
option.addClass("active");
|
||||
@@ -50,6 +59,12 @@
|
||||
wrapper.append(option);
|
||||
});
|
||||
|
||||
wrapper.find("span.option").click(function (){
|
||||
wrapper.find("span.option").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
self.val($(this).attr('value'));
|
||||
});
|
||||
|
||||
$(this).after(wrapper);
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user