views:

138

answers:

2

This function call ResizeableTextbox('myRT'); works well inside javascript(produces a resizeable text box) but doesn't work inside jQuery code.Why?

This produces the resizeable textbox.

<script type="text/javascript">
ResizeableTextbox('myRT');
</script>

But if I give it like this in the jquery code,I dont get the resizeable textbox.

$(".select").change(function () {          
       $(".select"+increment+" option:selected").each(function ()    
       {              
         if($(this).text() =='String')
         {
           $("<label id=labelid >"+label+"</label>").appendTo(".menu li");    
           ResizeableTextbox('myRT');//this does not work.How else to code?
         }
       });
 });

Is there any method for function call in jQuery?

Update:

The function call ResizeableTextbox('myRT'); doesn't work anywhere within the jQuery code. It works only inside <script>.

How else to write this function call? some one help me please..

+2  A: 

You want to append the resizable textbox to .menu li? You could do this:

var rt = new ResizeableTextbox('myRT'); //this is for making resizeable text box
$('.menu li').append(rt);

However Im not quite sure if this is what you wan't. Your question is rather vague.

Pim Jager
ya.. you are correct.. I want to append the resizeable text box to .menu li. Previously I just had a text box,$("<input id=inputstr type= 'text' ></input>").appendTo(".menu li");Now instead of this I need the resizeable text box.If I code what you had said,it throws error.. the page goes blank..
Angeline Aarthi
+2  A: 

It depends greatly on exactly what 'rt' will contain and how it is then added to the DOM.

If it just contains HTML then obviously $(parentSelector).html(rt) would solve the problem. If it returns a DOM element then $(rt).appendTo(parentSelector); If it something else, or is added to the DOM inside your ResizeableTextbox code then I couldn't possibly guess.

Update: If you are using the resizable textbox detailed here: http://www.switchonthecode.com/tutorials/javascript-controls-resizeable-textbox then you would use the following code:

$(document).ready(function() {
  var rt = new ResizeableTextbox();
  $('#resizable').append(rt.GetContainer());
  rt.StartListening();
});
samjudson
rt is a text box that can be resized.
Angeline Aarthi
Yes, but is it a string of HTML, or a DOM element or something else?
Colin Fine
Updated answers.
samjudson
@ samjudsonI also tried what you have given:var rt=new ResizeableTextbox('myRT'); $(parentSelector).append($(rt.GetContainer()));no result. The page goes blank( says page loading)
Angeline Aarthi
The function call ResizeableTextbox('myRT'); doesn't work anywhere within the jQuery code. It works only inside `<script>`.How else to write this function call?
Angeline Aarthi
Err, not sure what you mean. Your jquery code should be in a script.
samjudson
Its actually not jquery code,it's a java script code..So it works only within <script></script>.I'm not able to use it inside the $(document).ready() function. The page goes blank(says page is loading).Please help me out with this.
Angeline Aarthi
jquery IS javascript. Both should be within a <script></script> element. I can't see you code so I don't have any idea why it still says 'page loading'. The code I gave above works fine for me.
samjudson