.Button , live jQuery.
$('.Button').live('click', function() {
$tabs.tabs('load', $tabs.tabs('option', 'selected'));
return false;
});
, .Button , return false; .
, , , , . (URL- ). , , eval() script ( ?).
, , .
, json, , json:
({
"items": [
{ "title": "example 1" },
{ "title": "example 2" },
{ "title": "example 3" },
{ "title": "example 4" },
{ "title": "example 5" },
{ "title": "example 6" },
{ "title": "example 7" },
{ "title": "example 8" },
{ "title": "example 9" },
{ "title": "example 10" }
]
})
Script
$(function() {
var $tabs = $(".Tabs").tabs({
selected: null,
select: function(event, ui) {
loadTab( ui.index );
}
});
$('.Button').live('click', function() {
loadTab( $(".Tabs").tabs('option', 'selected') );
return false;
});
$('.Tabs').tabs('select',0);
});
function loadTab(indx){
$.ajax({
type: "GET",
url: "http://domain.com/Service.svc/get",
dataType: "json",
success: function(data) {
var content = "";
$.each(data.items, function(items){
content += "<a class='Button' href='#'>" + this.title + "</a><br>";
});
$("#Content").html(content + "<br />Tab Index #" + indx + " on " + (new Date()).toUTCString());
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (!$('#error').length) $("#Content").prepend('<div id="error"></div>');
$('#error').html(textStatus + '<br /><br />');
}
})
}