File: D:/HostingSpaces/RClaassen/stay-on-track.nl/wwwroot/javascript/bedrijf.js
$(document).ready(function() {
$.ajaxSetup( { type: "post" } );
$( "#new_location" ).autocomplete({
source: function(request, response) {
$.ajax({
url: '/vacatures/index.php?/bedrijven/bedrijven/autocomplete/',
dataType: "json",
data: {
term : request.term,
'bedrijf_id': $("#id").val(),
},
success: function(data) {
response(data);
}
});
},
minChars:2,
select: function (event, ui) {
window.locatie_id = ui.item.id;
},
});
$("#add_locatie").click(function(event) {
event.preventDefault();
if(window.locatie_id > 0) {
$.post("/vacatures/index.php?/bedrijven/bedrijven/add_locatie", {
'bedrijf_id': $("#id").val(),
'locatie_id': window.locatie_id,
},
function(data,status) {
var newRow = $(data);
$("#logorow").after(newRow);
$("#new_location").val("");
window.locatie_id = 0;
}
);
}
});
function deleteCompanyLocation(locatieId, bedrijfId) {
$.post("/vacatures/index.php?/bedrijven/bedrijven/del_locatie", {
'locatie_id': locatieId,
'bedrijf_id': bedrijfId,
},
function(data, status) {
$('#' + locatieId).remove();
}
);
}
window.deleteCompanyLocation = deleteCompanyLocation;
});
var locatie_id;