i have this code as i need to load a url.action with different parameters in a loop (multiple links)
Im having a couple of problems, first only the first link in the foreach loop actually does anything
Second problem is the controller is expecting id as an int and name as a string which isnt working so nothing loads? if i change the id and string in the 'link' manually it works
I have put both the values into a window.alert and it shows the javascript is getting the correct values, just dont think they are being recieved by the controller as correct string/int??
Javascript
<script type="text/javascript">
$('#changetopicss').click(function () {
$('#loadingAjaxs').show();
$('#flubestext').hide();
var link = '@Url.Action("Detail", "Topics", new { @id = -1, @name = -2, @forum = "all", @page = 0})';
link = link.replace("-1", $(this).data('id'));
link = link.replace("-2", $(this).data('shortname'));
// window.alert(dataname);
$('#contentwrap').load(link, function () {
$('#loadingAjaxs').hide();
$('#flubestext').show();
window.history.pushState(null, 'title', '/topics');
});
});
</script>
Links created dynamically in a for each loop
<a id="changetopicss" data-id='@following.Id' data-shortname='@following.ShortName'>@following.Title</a>
Controller Header
public ActionResult Detail(int id, string name, string forum, int page)