Given I have:
$("a.clickable").livequery('click', (function (e) {
var values = $(this).attr('id').split('_');
$('#' + values[3]).load($(this).attr('href'));
e.preventDefault();
}));
You see, I want all links with the class “clickable” to cause an ajax load. The target div however varies, so I´ve simply put this – along with some other data – into the Id´s link:
“link_value1_value2_targetDivId”.
So I currently split the id to get an array of values to work with.
I know about *$(obj).data()*, but I need to pass some stuff on serverside.
Is there a ways to achieve this without this ugly id-string-parsing? ASP.Net/MVC btw.
No You can’t do that. All that triggering of the AJAX calls has to be done from the client side, though there are ways where you can push some data to client from the server using reverse AJAX or comet but that is not what you are looking for. For your case, you have to do that ugly logic. But if you don’t want to parse it, you can store the id in the element itself as data/custom attribute and use it instead of parsing.