I try to select JSF component by using jQuery selector. Composite component .xhtml and .js relative code are separated, so I pass cc.cliendId
in variables as following:
var variables = {};
variables.formid = "#{cc.clientId}";
And in *.js file I try to use it as following: $('[id="'+variables.formid+'"]')
it works and returns me a whole div, but the following code doesn't work, it returns an empty object []
:
function escapeColons(selector) {
return selector.replace(/(!|"|#|\$|%|\'|\(|\)|\*|\+|\,|\.|\/|\:|\;|\?|@)/g, function($1, $2) {
return "\\\\" + $2;
});
}
$("#" + escapeColons(variables.formid))
The function which escapes colons is taken from this answer: https://stackoverflow.com/a/4792023/947111
If I write $("#" + "form\\:range_chooser")
, range_chooser is a id of my composite component, it works.