0

I have this code in my HTML document and I would life to bind click event on such elements.

<gui:button id="btnTest">
  <label>Compose mail</label>
  <click>someaction()</click>
</gui:button>

I tried this two methods in my document.ready function, but none of them work

$('gui\:button').click(function() { alert('clicked'); });
$('button').click(function() { alert('clicked'); });

Is there any other way to bind click event to such elements?

4
  • 3
    ...what is a gui:button? :) More importantly, how does it render on the client? Commented Sep 9, 2010 at 15:02
  • 1
    can u please post the resultant HTML markup ? Commented Sep 9, 2010 at 15:04
  • i far as i know namespaces in xml documents are declared like this xmlns:something="url" ... this is why i wrote namespaces ... and added tag xml-namespaces on this thread ... dont question why i'm am using namespaces that way ... i just need it to work like this Commented Sep 9, 2010 at 15:15
  • i figured it out ... thanks for the help ... btw ... this application is for specific browser use ... so i can use non standard notations Commented Sep 9, 2010 at 15:24

2 Answers 2

2

Binding the event to the ID will be quickest:

$('#btnTest').click(function() { alert('clicked'); });
Sign up to request clarification or add additional context in comments.

2 Comments

If the content is being dynamically injected into the page via AJAX then review the .live() or the .delegate() methods also.
I figured it out ... $('gui\\:button').click(function() { alert('clicked'); });
1

Use two backslashes in the jQuery selector: $('gui\\:button').click(...)

(reposting Mitja's rather helpful comment as an answer, because it's too invisible otherwise)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.