HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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;