jQuery selectable filter

preview_player
Показать описание
Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

In this video we will discuss jQuery selectable filter option with an example. Along the way we will also discuss destory method. This is continuation to Part 97. Please watch Part 97 from jQuery Tutorial before proceeding.

Here is what we want to be able to do
When "Exclude Weekends" checkbox is checked, we should not be able to select weekends (Sat and Sun)
When "Exclude Weekends" checkbox is not checked, we should be able to select all days including weekends (Sat and Sun)

Code used in the demo

<%@ Page Language="C#" AutoEventWireup="true"

<!DOCTYPE html>
<head runat="server">
<title></title>
<script type="text/javascript">
$(document).ready(function () {
var selectableList = $('#selectable');

stop: getSelectedItems
});

function getSelectedItems() {
var selectedItems = '';
$('.ui-selected').each(function () {
selectedItems += $(this).text() + '<br/>';
});

$('#result').html(selectedItems);
}

function createSelectableList(filterValue) {
stop: getSelectedItems,
filter: filterValue
});
$('#selectable li').removeClass('ui-selected');
$('#result').empty();

var weekends = $('li[data-value="weekend"]');
if (filterValue == '*') {
}
else {
}
}

$('#cbExclude').click(function () {
if ($(this).is(':checked')) {
createSelectableList('li[data-value="weekday"]');
}
else {
createSelectableList('*');
}
});
});
</script>
<style>
li {
display: inline-block;
border: 1px solid black;
padding: 20px;
cursor: pointer;
}

.ui-selecting {
background-color: grey;
color: white;
}

.ui-selected {
background-color: green;
color: white;
}

.excluded {
background-color: red;
color:white;
cursor:default
}
</style>
</head>
<body style="font-family: Arial">
<form id="form1" runat="server">
Exclude Weekends :
<input id="cbExclude" type="checkbox"/>
<ul id="selectable">
<li data-value="weekday">Mon</li>
<li data-value="weekday">Tue</li>
<li data-value="weekday">Wed</li>
<li data-value="weekday">Thu</li>
<li data-value="weekday">Fri</li>
<li data-value="weekend">Sat</li>
<li data-value="weekend">Sun</li>
</ul>
You selected :
<div id="result"></div>
</form>
</body>
</html>
Рекомендации по теме
Комментарии
Автор

Sir you have explained about json array retrival in jquery ajax by using webservices. but if we host tht webservices in iis   and try to retriving tht json array by using jqury ajax is not working..can you explain why is it so?

salmankotheri
Автор

Hello sir Please explain how to read max and min value from database table for part 79 range slider. I am a regular viewer of your presentation its really nice and unique.

subratkar