getting (this) at different function

Posted by twen_ta on Stack Overflow See other posts from Stack Overflow or by twen_ta
Published on 2010-05-10T21:13:28Z Indexed on 2010/05/10 22:04 UTC
Read the original article Hit count: 121

Filed under:

I have couple of input fields with the class "link". All of them should start the jqueryUI dialog so this is why I bind the method to a class and not an single id. The difficulty is now that i can't use the (this) in line 12, because that gives me the identity of the dialog and not the input element.

As I am an beginner I don't know how to pass a variable to this event with the element of the input field.

What I want to archive is that the dialog should start from the input field and should write the result back to that input field.


   1.     // this is the click event for the input-field class called "link"
   2.     $('.link')
   3.         .button()
   4.         .click(function() {
   5.             $('#dialog-form').dialog('open');
   6.         
   7.         });  
   8.    
   9.     //this is an excerpt from the opened dialog box and the write back to the input field
  10.     $("#dialog-form").dialog({
  11.                     if (bValid) {
  12.                         $('.link').val('' +
  14.                             name.val() + '');
  15.                         $(this).dialog('close');
  16.                     }
  17.    });

© Stack Overflow or respective owner

Related posts about jQuery