Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter LadyLain

    (@ladylain)

    Hi

    Thanks for the answer,

    I’ve followed your advice and just optimized it.

    in the file job-board-manager-locations/assets/admin/js/scripts.js

    jQuery(document).ready(function($)
    	{
    		
    		$("#job_bm_location").attr('autocomplete','off');		
    		$("#job_bm_location").wrap("<div id='location-list-wrapper'></div>");
    		
    		$("#location-list-wrapper").append("<div id='location-list'></div>");		
    
    		$(document).on('keyup', '#job_bm_location', function()
    			{
    				
    				var name = $(this).val();
    				name = name.split(',');
    				name = name[name.length-1];
    				console.log(name);
    				
    				if(name=='' || name == null){
    						$("#location-list").html('<div value="" class="item">Start Typing...<div>');
    					}
    				else{
    					
    					$.ajax(
    						{
    					type: 'POST',
    					context: this,
    					url:job_bm_locations_ajax.job_bm_locations_ajaxurl,
    					data: {"action": "job_bm_locations_ajax_job_location_list", "name":name,},
    					success: function(data)
    							{	
    								$("#location-list").html(data);	
    							}
    						});
    					
    					}
    				
    			})
    
    		$(document).on('click', '#location-list .item', function(){
    				var oldval = $('#job_bm_location').val();
    				var inputVal = oldval.split(',');
    				var newVal ='';
    				for (var i = 0; i < inputVal.length-1; i++) {
    				 	if (newVal=='') {
    				 		newVal = inputVal[i];
    				 	}else{
    				 		newVal = newVal+','+inputVal[i];
    				 	}
    				 	
    				}
    				var name = $(this).attr('location-data');
    				if (newVal=='') {
    					newVal = name;
    				}else{
    					newVal = newVal+','+name;
    				}
    				
    				$("#job_bm_location").val(newVal);
    			
    			})
    
    	});

    So, if I write a comma after the text it browses again into all locations post, and i can choose one.

    And to display i’ve done this in job-board-manager/templates/job-single-sidebar.php

    if(!empty($job_bm_location)){
    		$job_bm_location = split(',', $job_bm_location);
    
    		foreach ($job_bm_location as $location) {
    			$html_about_company .= '<div itemprop="jobLocation" itemscope itemtype="http://schema.org/Place"  class="side-meta location"><i class="fa fa-map-marker"></i> '.$location.'</div>';
    		}
    		
    	}

    Now, i just have to look at my ajax research to make it work with this

    hope it can help somebody 🙂

    i had the same issue few days ago, and what i’ve done is to change into the code the editor used, and replaced it by the tinyMCE editor which take HTML tags

    Hope it can help you !

Viewing 2 replies - 1 through 2 (of 2 total)