views:

26

answers:

2

Hello

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?

A: 
jQuery(function(){
          var _length= $(.cssDockZone).length;
});
Praveen Prasad
What are you trying to do? I dont understand. My problem is that the client script is called before the controls are created.
NLV
this way "var _length= $(.cssDockZone).length;" part will be run after client controls created and in DOM and DOM is ready.
Praveen Prasad
A: 

I was using '.' before the css class name while assigning them to the control. Silly. Removing the '.' fixed it.

NLV