getting (this) at different function
- by twen_ta
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. });