nelsonm

msg:4471926 | 8:22 pm on Jul 2, 2012 (gmt 0) |
What i'd like to do is bind the click method to the button in the ui-dialog-buttonpane who's span element text is "Submit". This way the click method will always work on the submit button even if another button is added to the dialog iu-dialog-buttonpane. The only unique thing in the dynamically generated jquery dialog button pane is the name of the buttons contained as text in the span tag for each button. I just can't figure out if this can be done.
|
Fotiman

msg:4471958 | 10:58 pm on Jul 2, 2012 (gmt 0) |
How about this: $(this).find(".ui-button-text:contains('Submit'):parent").click(); I haven't tried it, but I think that would do what you're trying to do.
|
nelsonm

msg:4471960 | 11:48 pm on Jul 2, 2012 (gmt 0) |
Fotiman, thanks again - that worked. I was reading up on the :contains() and :parent selectors in the jquery selector docs. I didn't realize you could combine them to get the parent (the button tag) of the span element tag. How did you know you could combine them that way? Or am i just missing the point that they are merely selectors and selectors can be combined.
|
nelsonm

msg:4471974 | 12:52 am on Jul 3, 2012 (gmt 0) |
Fotiman, I wrote the selector to the console.log. It appears that jquery is ignoring the :parent selector. i removed :parent from $(this).find(".ui-button-text:contains('Submit')").click(); and it still worked. The click method appears to be bound to the span tag - but it still works.
|
Fotiman

msg:4472007 | 3:05 am on Jul 3, 2012 (gmt 0) |
Glad it worked. :) jQuery's selectors are pretty powerful, so I just figured that more accurately represented what you were trying to select.
|
nelsonm

msg:4472020 | 4:43 am on Jul 3, 2012 (gmt 0) |
Fotiman, it appears that: $(".ui-button-text:contains('Submit')").parent().click(); or $(this).find(".ui-button-text:contains('Submit')").parent().click(); also work and both (minus the .click) resolve to "button.ui-button".
|
|