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
NeedHelp55NeedHelp55 

action function is not working.Please Help.

I am trying to build a report wizard. What i am doing is that dragging a field form one table & dropping it to a div. I want  actionfunc() to be called when a field is dropped to droppable section. I have defined that in my page.But it is not working.

 

///////////////////////////////////////////////visualforce page///////////////////////////////////////////////

 

<apex:page id="page" sidebar="false" controller="describe">
<apex:includeScript value="{!URLFOR($Resource.jqueryStable, '/js/jquery-1.7.2.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jqueryStable, '/js/jquery-ui-1.8.20.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.jqueryStable, '/css/cupertino/jquery-ui-1.8.20.custom.css')}"/>

<style>
p{
text-transform:uppercase;
font-family:"Times New Roman", Times, serif;
color:#61210B;
}


.insertImage{background-image:url(http://www.wbsonline.com/images/icon-search-small.gif);
text-align:center;
background-repeat:no-repeat;
padding:10px;
height:0.1px;
width:170px;
font-family:Tahoma;
font-size:14px;
color:#000000;
}
</style>

<script type="text/javascript">

$(function() {
$(".account-Field").draggable({
helper: "clone",
revert: "invalid"
});

$("#content").droppable({
accept: ".account-Field",
drop: function( event, ui ) {
var fieldName = j$(ui.draggable).text();

rerenderPb1();
alert('Hello all');
}
});
//***************************************************//
// modal show //
//***************************************************//

function pleaseWait() {
j$('#content').modal('show');
}


});



</script>

<apex:form id="formid">

<apex:actionFunction name="rerenderPb1" action="{!actionfunc}" status="loadingstatus">
<!--apex:param id="param1" name="node1" value=""/-->
</apex:actionFunction>

<apex:actionStatus id="loadingstatus" onstart="pleaseWait();"/>

<apex:pageBlock title="Report Wizard" id="pb1">
<apex:pageBlockSection columns="3">

<apex:outputPanel >
<p>Search:</p>
<apex:inputText value="{!fieldName}" id="theInputText" styleClass="insertImage" onkeyup="ItemSearch()"/>
<div style="overflow-y:scroll; width:200px; height:400px">
<apex:pageBlocktable value="{!lstOfLabel}" var="da" id="pbt1" title="MY TABLE" >
<apex:column styleClass="account-Field" value="{!da.labelValue}"/>
</apex:pageBlocktable>
</div>
</apex:outputPanel>

<div id="content" style="background-color:#EEEEEE;height:400px;width:800px;float:left;">

</div>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

/////////////////////////////////class///////////////////////////////////////////////////////

 

public class describe {

Public List<String> fields{get;set;}
public List<WrapperFieldDetails> lstOfLabel{get;set;}
public Integer counter{get;set;}
public List<WrapperFieldDetails> selectedField{get;set;}
public List<Account> searchResList { get; set; }
Public String fieldName{get;set;}
Public List<sObject> recordList {get; set;}
Public static List<String> selectedFieldList {get; set;}

Public describe()
{
Map<String, Schema.SObjectField> fieldMap= Schema.SObjectType.Account.fields.getMap();
lstOfLabel=new List<WrapperFieldDetails>();
counter=1;

for (String fieldName: fieldMap.keySet())
{
WrapperFieldDetails wca = new WrapperFieldDetails();
wca.idOfEachField=counter;
//wca.isSelected=false;
wca.labelValue=fieldMap.get(fieldName).getDescribe().getLabel();
lstOfLabel.add(wca);
counter=counter+1;
}
}

Public void actionfunc()
{
system.debug('action method is fired');
}

public class WrapperFieldDetails
{
public Integer idOfEachField{get;set;}
public String labelValue{ get; set; }
//public Boolean isSelected{get;set;}
}
}

Best Answer chosen by Admin (Salesforce Developers) 
NeedHelp55NeedHelp55

Hey... i got my solution . if i use var fieldName =  $(ui.draggable).text() instead of  var fieldName =  j$(ui.draggable).text() .Then it's working.

 

Thanks for your valuable time.

All Answers

kiranmutturukiranmutturu
r u getting the alert what you gave in the script?
NeedHelp55NeedHelp55

if i use the alert before var fieldName =  j$(ui.draggable).text() then it shows the alert else not.

kiranmutturukiranmutturu

are you getting any errors on the page load ? i mean browser errors also put <apex:pagemessages/> tag so that we can track the errors if any...

NeedHelp55NeedHelp55

I am using chrome latest version & it's showing no any errors.

kiranmutturukiranmutturu

just try this
change the actionfucntion code like
<apex:actionFunction name="rerenderPb1" action="{!actionfunc}" status="loadingstatus" rerender="op">
<!--apex:param id="param1" name="node1" value=""/-->
</apex:actionFunction>

and add the below line

<apex:outputpanel id="op" rendered="false"/>

NeedHelp55NeedHelp55

Hey... i got my solution . if i use var fieldName =  $(ui.draggable).text() instead of  var fieldName =  j$(ui.draggable).text() .Then it's working.

 

Thanks for your valuable time.

This was selected as the best answer
kiranmutturukiranmutturu
so finally its jquery error...ok great u cracked anyways.. Happy coding...
Andrew B. DavisAndrew B. Davis
FYI, sometimes this issue can occur because of the placement of the <apex:form> tags relative to the <apex:actionFunction> tags. I was having this problem with many actionFunctions, and the solution was to break the page into several <apex:form> elements, surrounding the ActionFunction and the fields directly related to it.