filterJobs: function()
{
var team = $('#selectOne').val();
var specialty = $('#selectTwo').val();
var level = $('#selectThree').val();
//var defSelectTeam=
$('.jobs').hide()
.filter('[data-team="' + team + '"][data-specialization="' + specialty + '"][data-level="' + level + '"]')
.show();
var newNumJobs = $('.jobs:visible').length;
$('table:visible:odd').css({'background-color': ' #F1F1F1'});
$('table:visible:even').css({'background-color': '#FFFFFF'});
if (newNumJobs <= this.pageSize)
{
$("#dvJobs span").text("Showing " + newNumJobs + " of " + newNumJobs + " jobs");
}
else
{
$("#dvJobs span").text("Showing " + this.pageSize + " of " + newNumJobs + " jobs");
}
this.buildPaginator(newNumJobs);
},
嗨任何線索如何,現在修改爲選擇濾波這種過濾功能它的作品,我需要設置一個默認值,顯示對變化的濾波前所有選項?我只需要指出正確的大方向,我對js很吝嗇,但是試圖改進。在此先感謝, 的HTML是這個//////,它的工作原理是取數據屬性關閉表,這部分工作正常,只需要設置一個默認值,我想設置幾個數據ATTRS的,但似乎很混亂。或者設置一個檢查值的if塊,如果它的'select one'顯示全部。對不起,漫不經心。設置默認值
<select id="selectOne">
<option value="Select One">Select One </option>
<option value="Engineering">Engineering </option>
<option value="SoftwareDevelopment" >Software Development</option>
<option value="HumanResources" >Human Resources</option>
<option value="MarkettingAndSales">Marketting and Sales</option>
<option value="Administrative">Administrative</option>
<option value="Others">Others</option>
</select>
<label>Specialty:</label>
<select id="selectTwo">
<option class="Select One" >Select One </option>
<option class="MarkettingAndSales" value="Sales">Sales </option>
<option class="HumanResources" value="Recruitment">Recruitment </option>
<option class="Administrative" value="OfficeGeneral">Office General </option>
<option class="Engineering SoftwareDevelopment" value="WebDevelopment">Web Development </option>
<option class="SoftwareDevelopment" value="ApplicationDevelopment">Application Development </option>
<option class="SoftwareDevelopment" value="UIUXDesign">UI/UX Design</option>
<option class="Others" value="ScientificResearch">Scientific Research</option>
<option class="Engineering Others" value="ComputerHardwareNetworking">Computer Hardware Networking</option>
<option class="Others" value="Others">Others</option>
</select>
<label>Level:</label>
<select id="selectThree">
<option>Senior</option>
<option>Intermediate</option>
<option>Junior</option>
</select>
在此先感謝。 更新:我修改了一點,以顯示分頁,但我想我現在用的是VAL函數出錯了的if/else塊?
filterJobs: function()
{
var team = $('#selectOne').val();
var specialty = $('#selectTwo').val();
var level = $('#selectThree').val();
var newNumJobs = $('.jobs:visible').length;
if (team === 'SelectOne' && specialty === 'SelectOne')
{
$('.jobs').show();
}
else
{
$('.jobs').hide()
.filter('[data-team="' + team + '"][data-specialization="' + specialty + '"][data-level="' + level + '"]')
.show();
$('table:visible:odd').css({'background-color': ' #F1F1F1'});
$('table:visible:even').css({'background-color': '#FFFFFF'});
}
if (newNumJobs <= this.pageSize)
{
$("#dvJobs span").text("Showing " + newNumJobs + " of " + newNumJobs + " jobs");
}
else
{
$("#dvJobs span").text("Showing " + this.pageSize + " of " + newNumJobs + " jobs");
}
this.buildPaginator(newNumJobs);
}
爲了澄清,我添加了tabe被過濾,希望能幫助理解我的問題。
<table data-team="<?php print $name['team']; ?>" data-specialization="<?php print $name['speciality']; ?>" data-level="<?php print $name['level']; ?>" cellpadding="0" cellspacing="0" border="0" width="670px" class="jobs"><tr><td>
<tr><td colspan="4"><strong>Research Assistant</strong></td>
<td></td><td></td><td></td></tr>
<tr>
<td width="100">Location : </td>
<td colspan="3">Madrid</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Job Code : </td>
<td width="460">6767676</td>
<td></td>
<td></td>
</tr>
</table>
'數據'屬性似乎是一樣好方法,因爲任何其他的。不清楚默認問題是什麼 – charlietfl
默認問題是,在調用過濾器時,所以沒有選項顯示,我希望在我開始調用過濾器函數之前加載所有內容。 – Ego
只激活選擇的'change'處理程序中的過濾器。可疑你需要運行它時,頁面加載,除非你具備的條件,其中的頁面加載預設選項中選擇 – charlietfl