[eluser]123wesweat[/eluser]
Hi,
I am stuck with the following, clicking the back button will not show the search results again but it shows just the regular overview.
Here's my controller setup:
controller jobs.php
function index() -> just an overview
function ajaxSearchJobs() ->returns a list of jobs base on searchFilters, will be loaded in a div
I am using jquery ajax call, which calls controller's method and outputs a list of jobs based on the different search filters.
This is the javascript i have in template.php view which holds the jquery and ajax function
Code:
function generate_query(){
frm=document.forms["filterjobs"];
qry="runquery=1";
for(z=0;z<frm.elements.length;z++){
if(frm.elements[z].type=="select-one" && frm.elements[z].options.selectedIndex>0){
qry += "&" + frm.elements[z].name + "=" + frm.elements[z].options[frm.elements[z].options.selectedIndex].value;
}
}
//ajax querystring
alert(qry);
$.ajax({
type: "POST",
url: "jobs/ajaxSearchJobs",
data: qry,
beforeSend: function() { $('#wait').show(); },
complete: function() { $('#wait').hide(); },
success: function(msg){
//check what is returned
//alert( "Data Saved: " + msg );
$('#searchResult').html(msg); // Fill the search results box
}
});
//end search result
}
Explanation: Each dropdown menu triggers the javascript function generate_query() and shows a list of found jobs. But when you click on the details link of a particular job it calls
and it shows the details.
But when you click the back button it doesn't show the previous result but the default overview.
How can i fix this??
Second question would be how i can get the pagination to work?
My ajaxSearchJobs method/function looks like this
Code:
function ajaxSearchJobs() {
$runquery = isset($_POST['runquery']) ? $_POST['runquery'] :'';
$searchItemA= isset($_POST['searchItemA']) ? $_POST['searchItemA'] :'';
$searchItemB= isset($_POST['searchItemB']) ? $_POST['searchItemB'] :'';
$searchItemC= isset($_POST['searchItemC']) ? $_POST['searchItemC'] :'';
$searchItemD= isset($_POST['searchItemD']) ? $_POST['searchItemD'] :'';
if($runquery==1) {
//search the DB
$data['jobsfound'] = $this->jobs_model->filter_jobs($runquery, $searchItemA,$searchItemB,$searchItemC,$searchItemD);
$data['tableResult'] = $this->load->view('vacatures/view_filter_results', $data, TRUE);
//for ajax we just need to echo which is our msg var???
echo $data['tableResult'];
//$this->load->view('jobs/template', $data);//<-we don't need this????
} else {
//not direct access
echo "No direct search";
}
}
regards