Access a dynamically created control through javascript - ASP.NET
I've a JavaScript function in my page through which开发者_运维技巧 i make some elements in the page as 'JQuery UI droppable'.
function setDroppableTargets()
{
$(.cssDockZone).droppable();
}
But the elements with the class cssDockZone is created dynamically upon user interaction. So in the code behind i create the control first and finally at the end i register a scriptblock which calls setDroppableTargets().
//set droppable targets
ClientScript.RegisterClientScriptBlock(this.GetType(), "setDroppableTargets", "setDroppableTargets()", true);
But the javascript function is invoked before the controls are created eventhough i register the script at the end (after creating the controls) and i cross checked it by getting the elements with class name '.cssDockZone' and i getting it as 0.
$(.cssDockZone).length
Any ideas?
jQuery(function(){
var _length= $(.cssDockZone).length;
});
I was using '.' before the css class name while assigning them to the control. Silly. Removing the '.' fixed it.
精彩评论