0

I'm using jsf 2.0 ,richfaces 4.0 to implement my application. I used some times jQuery & javascript function for show & hide. But when I generate tags in xhtml page then it wont allow me.

Foe e.g: I want to append image for rich:autocomplete component of jsf for each serach result. So I write the code like this:

<script type="text/javascript">
function addPhotoPage(){
    var allDiv=$('#frmContent\\:txtPatientSearchItems').find('div');
    $.each(allDiv,function(cnt,data){
   $(this).append("<img src="./resources/images/photo.png">");
    });
}
</script>

this code written in xhtml page.

JSF strictly checks all the tags so it wont allow me to append img tag to result of search.

Thank you.

1 Answer 1

2

The first thing you have to know is that Richfaces is provided with both Prototype and jQuery. Thus, $ does not refer to jQuery, but to Prototype. You should use directly jQuery instead of $ in your code.

The second thing you should consider is to use ' instead of " for the definition of your <img> attribute.

Finally, you can simplify your jQuery code.

So try to change your code to:

function addPhotoPage() {
    jQuery("#frmContent\\:txtPatientSearchItems").find("div").append("<img src='./resources/images/photo.png'>"));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.