2 Replies Latest reply on Jul 7, 2011 8:01 AM by Nikita Sumeiko

    Returning DOM element for passed short id served dynamically as JS function parameter

    Nikita Sumeiko Newbie

      I have created a JavaScript function, which has to return DOM object by specified id of RichFaces element.

      The reason of doing this is very simple - I need to get DOM object by id and RichFaces makes their ids complicated to be reached via jQuery or getElementById() simple JavaScript function. Therefore, if I return an object and save it in private variable, I would be able to use it as I wish.

       

      Here's a function:

       

      function getRichObject(id){
           var object = #{rich:element(id)};
           return object;
      }
      
      console.log( getRichObject('element_id') );
      

       

      However, when I call a function, as you see in console.log() example above, JavaScript error appears in the Firebug console:

      syntax error

      var object = ;

       

      I hope experienced RichFaces developers has already faced that problem and could give me a tip?!