jQuery + MVC3 : Return ID of images populated through controller action
I am using .net mvc 3 to develop web app. Currently I got a view page which i generate a list of images through my controller action method:
public string GetContainersImg()
{
string output = "";
var containersImg = dbEntities.ContainerTypes.GroupBy(t => t.ContainerTypeName).ToList();
foreach (var item in containersImg)
{
foreach (var img in item)
{
output += "<div class=\"image\"><img id=\"" + 开发者_运维技巧img.ContainerImgName + "\" src=\"" + img.ContainerImg + "\"/></div>";
}
output += "<br />";
}
return output;
}
I want to retrieve the id of my image at my view, but i realise that using the jQuery command: var id = ui.draggable.attr('id');
do not return me the ID. i wonder is it because my html is generated from controller action.
Anyone can help???
Thanks!
Found out the mistake i made. ui-draggable here is refer to the but not the image. Got it by calling ui.draggable.children() . I not sure is it a bad way though
精彩评论