function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MMA_FORCEMMA_FORCE 

Place apex VF Tags outside of javascript????

How would I place my datatable tags outside the javascript tags and just have the outputtext value appear...???

 

<script type="text/javascript"> $(document).ready(function(){ j$("input#e").myfun({ source: ['<apex:dataTable value="{!Teach}" var="t"> <apex:outputText value="{!t.skc__Teacher__r.Name}"/></apex:dataTable>'] }); }); </script>

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
stephanstephan

The other thing you could do is wrap your datatable inside of a div like so:

 

 

<div id="theDataTable" style="display:none"> '<apex:dataTable value="{!Teach}" var="t"> <apex:outputText value="{!t.skc__Teacher__r.Name}"/></apex:dataTable> </div>

 And then in your JS:

 

<script type="text/javascript"> $(document).ready(function(){ j$("input#e").myfun({ source: [ $("theDataTable").innerHTML ] }); }); </script>

 

 


 

All Answers

AvromAvrom

I don't think you can directly do exactly what you want here. VisualForce tags generate HTML, not just values. So that dataTable tag will, among other things, generate a <table> tag, and the outputText will generate a <span> surrounding its values.

 

You could get a bit closer (stripping out the table tags and other table stuff) by using <apex:repeat> tag instead of an <apex:dataTable>. But you'll still have to strip out the generated <span> and </span> tags yourself. Probably the safest way to do this is using JavaScript regular expressions (in case there are any additional attributes or whitespace in the span tags), as described here:

 

http://www.regular-expressions.info/javascript.html

 

Message Edited by Avrom on 03-05-2010 01:34 PM
stephanstephan

The other thing you could do is wrap your datatable inside of a div like so:

 

 

<div id="theDataTable" style="display:none"> '<apex:dataTable value="{!Teach}" var="t"> <apex:outputText value="{!t.skc__Teacher__r.Name}"/></apex:dataTable> </div>

 And then in your JS:

 

<script type="text/javascript"> $(document).ready(function(){ j$("input#e").myfun({ source: [ $("theDataTable").innerHTML ] }); }); </script>

 

 


 

This was selected as the best answer