I am trying to set the tab focus on current item when i click any button but the focus goes to the start of the page
var ve = ve || {};
ve.woningoverzicht = (function() {
'use strict';
function init() {
databind();
$('form').removeData('validator');
$('form').removeData('unobtrusiveValidation');
$.validator.unobtrusive.parse('form');
}
function databind() {
$.validator.setDefaults({
ignore: ""
});
$(document).on('click', '#SelecteerAndereErkendDeskundige', function () {
$(this).attr('disabled', 'disabled');
});
$(document).on('click', '#btnzoekinwoningen', function () {
getWoningZoekenPage(0);
});
$(document).on('click', '#btnHerstelZoekOpties', function () {
getWoningPage(0);
});
$(document).on('change', '#woning-overzicht-zoek-form :input', function () {
$.validator.unobtrusive.parse('form');
});
$(document).on('click', '.woning-overzicht-goto-pagina', function () {
getWoningPage(parseInt($(this).data("goto-pagina")));
});
$(document).on('click', '.woning-overzicht-zoeken-goto-pagina', function () {
getWoningZoekenPage(parseInt($(this).data("goto-pagina")));
});
}
return {
init: init
};
function getWoningZoekenPage(paginaNummer) {
if (!$('#WoningZoeken_Postcode').valid() || !$('#WoningZoeken_Huisnummer').valid()) {
return false;
}
var zoekenViewModel = {
Postcode: $('#WoningZoeken_Postcode').val(),
Huisnummer: $('#WoningZoeken_Huisnummer').val(),
Toevoeging: $('#WoningZoeken_Toevoeging').val(),
Pagina: paginaNummer
}
$.ajax({
url: '/Woning/ZoekWoning',
type: 'post',
cache: false,
dataType: "json",
contentType: 'application/json',
data: JSON.stringify(zoekenViewModel)
})
.success(function (result) {
$("#woningen-overzicht-list").empty();
$("#woningen-overzicht-list").html(result.Zoekresultaat);
});
}
function getWoningPage(paginaNummer) {
$.ajax({
url: '/Woning/GetWoningOverzichtPage',
type: 'post',
contentType: 'application/json; charset=utf-8',
cache: false,
data: JSON.stringify({ Pagina: paginaNummer })
})
.success(function (result) {
$("#woningen-overzicht-list").empty();
$("#woningen-overzicht-list").html(result);
});
}
}());
Html page
@model DICTU.VEL.Presentation.Web.ViewModels.Woning.Pager
<div class="row">
<div class="col-md-20 col-md-offset-2">
<div class="text-center">
<nav>
<ul id="list" class="pagination">
@if (Model.CurrentPage > 1)
{
<li>
<a href="@Url.Action(VE.Woning.WoningOverzicht())" aria-label="Eerste">
<span aria-hidden="true">«</span>
</a>
</li>
<li>
<a href="javascript:void(0)" class="woning-overzicht-goto-pagina" data-goto-pagina="@(Model.CurrentPage-1)" aria-label="Vorige">
<span aria-hidden="true">‹</span>
</a>
</li>
}
@for (var page = Model.StartPage; page <= Model.EndPage; page++)
{
<li class="@(page == Model.CurrentPage ? "active" : "")">
<a href="javascript:void(0)" class="woning-overzicht-goto-pagina" data-goto-pagina="@page">@page</a>
</li>
}
@if (Model.CurrentPage < Model.TotalPages)
{
<li>
<a href="#" class="woning-overzicht-goto-pagina" data-goto-pagina="@(Model.CurrentPage+1)" aria-label="Volgende">
<span aria-hidden="true">›</span>
</a>
</li>
<li>
<a href="#" class="woning-overzicht-goto-pagina" data-goto-pagina="@Model.TotalPages" aria-label="Laatste">
<span aria-hidden="true">»</span>
</a>
</li>
}
</ul>
</nav>
</div>
</div>
</div>
<script type="text/javascript">
var ul = document.getElementById("list");
var items = ul.getElementsByTagName("a");
for (var i = 0; i < items.length; i++) {
items[i].onclick = function () {
alert('aaa');
this.focus();
return false;
}
}
</script>