Just wondered if this code could be optomiosed in anyway? It works great, just wanted to make sure there weren't any ways to simplify this or if there are any obvious errors in the markup. Asking primerly because of that second call in the first function, not sure if it's needed?
$(document).on("click", '.load', function (event) {
var $projects = $("#projects"),
id = $(this).data('id');
$projects.html("").data('id', id);
$("#loading").show();
$projects.load("projects.html #div" + id, function () {
$("#projects").show();
$("#loading").hide();
})
});
$(document).on("click", '.next', function (event) {
var $projects = $("#projects");
pid = $projects.data('id');
$projects.data('id', (pid == 6) ? 1 : (pid + 1));
$projects.load("projects.html #div" + $projects.data('id'));
});
$(document).on("click", '.previous', function (event) {
var $projects = $("#projects");
pid = $projects.data('id');
$projects.data('id', (pid == 1) ? 6 : (pid - 1));
$projects.load("projects.html #div" + $projects.data('id'));
});
$(document).on("click", '.exit', function (event) {
$("#projects").hide();
});