jQuery Mobile 1.4 - change page
$.mobile.changePage() is deprecated.
by Ilian Alexiev
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<input id='input' type='text' placeholder="Search term">
<ol id="listUl" data-role="listview" data-icon="false" style="margin-right: 5px;">
JavaScript
function search(data, term) {
return _.filter(data, function(x) {
return _.includes(_.toLower(x.title), _.toLower(term))
})
}
document.getElementById('input').addEventListener('change', function() {
var name = document.getElementById('input').value;
const data = [{
"video_url": "http://63.237.48.3/ipnx/media/movies/Zane_Ziadi_HQ.mp4",
"title": "Zane Ziadi"
}, {
"video_url": "http://63.237.48.3/ipnx/media/movies/DarBastAzadiHQ.mp4",
"title": "Darbast Azadi"
}, {
"video_url": "http://63.237.48.3/ipnx/media/movies/Cheghadr_Vaght_Dari_HQ.mp4",
"title": "Cheghadr Vaght Dari"
}, {
"video_url": "http://63.237.48.3/ipnx/media/movies/Mashaal_HQ.mp4",
"title": "Mashaal"
}, {
"video_url": "http://63.237.48.3/ipnx/media/movies/Red_Carpet_HQ.mp4",
"title": "Red Carpet"
}]
var result = search(data, name);
if (_.isEmpty(result)) {
console.log('Nothing found');
} else {
listHTML = $.map(result, function(entry, i) {
if (i == 0) {
return "<li class=\"itemListClass\" id=\"movieListId\" data-theme=\"b\" style=\"padding-top:25px;padding-left: 15px;line-height:70px\"><a style=\"font-size:1.5em;\" class=\"list\" href='" + entry.video_url + "'>" + entry.title + "</a></li>";
} else {
return "<li class=\"itemListClass\" id=\"movieListId\" style=\"padding-left: 15px;margin-left: 10px;line-height:70px\"><a style=\"font-size:1.5em;\" class=\"list\" href='" + entry.video_url + "'>" + entry.title + "</a></li>";
}
}).join('');
$("#listUl").append(listHTML).listview("refresh").trigger('create');
}
});