Solved

jquery flexigrid not getting updated on onClick event

Posted on 2008-06-10
7
1,594 Views
Last Modified: 2012-06-27
Hello Experts,
I have a drop down where I am displaying some name from the XML file, which ever is been selected from the drop down list box I am displaying results in the Flexigrid.
For some reason it is only functioning for the first on click event and it is not calling proxy.asp on the second click.
Please can someone advice If I am doing anything wrong here.
Many thanks for your help
Regards
Sam
0
Comment
Question by:newbie27
  • 5
  • 2
7 Comments
 
LVL 8

Author Comment

by:newbie27
Comment Utility
<table id="listDisplay1" style="display:none">                              
</table>

<SELECT name="drpLists" id="drpLists"  style="width:136px; line-height:18px; padding:0; margin:4px;"
><OPTION value="0">Select List</OPTION><OPTION value="test">test</OPTION></SELECT
><script>document.frmList.hidList.value=document.frmList.drpLists[document.frmList.drpLists.selectedIndex
].value;</script>

<a href="javascript:null;" class="button" id="viewList">View List</a>                  


 function viewList(){

  if($("#drpLists").val() == 0 || $("#drpLists").val() == "new"){

    alert('Please select a list');

  }else{

   

	getListRefs();	

	var sRefNos = $("#listRefnos").val();

	  

	$('#defaultResults').hide();

    var sViewQuery = "SF1=keyword&ST1="+sRefNos; 

      

	$("#listDisplay1").flexigrid

	 

     ({

        url: 'list_proxy.asp?a=results',       

        colModel : [                    

                        {display: '<input type="checkbox" name="chkAll" onclick="checkAll(this.checked)"/> All', name : 'chkDelete', width : 30, sortable : false, align: 'left'},

                        {display: 'Notes', name : 'notes', width : 50, sortable : false, align: 'left'},

           {display: 'Contact    ', name : 'pe_rev_name', width : 150, sortable : true, align: 'left'},

                    {display: 'Compnay Name  ', name : 'co_name', width : 200, sortable : true, align: 'left'},   

                    {display: 'Flag  ', name : 'action_flag', width : 150, sortable : true, align: 'left'},

                    {display: 'Group  ', name : 'co_group', width : 200, sortable : true, align: 'left'}                 

        ],

        buttons : [                             

                                {name: 'Delete', bclass: 'delete', onpress : removeFromList},

                                {separator: true}

                                ],                                      

        sortname: '',

        sortorder: 'asc',

        usepager: false,

        title: 'View List Manager',

        useRp: true,

        rp: 100,

        query : sViewQuery+'&Fields=ref_no,notes,pe_rev_name,co_name,action_flag,co_group',         

        showTableToggleBtn: true,                       

        width: 760,

        height: 350,

        onSuccess:function(){

                $(".edit_area").editable( function(value, settings) { return(value); }, 

                {     

                        submit    : "OK",

                        indicator : "process..........",

                        tooltip   : "Click to edit...",

                           style  : "inherit"

                }

                );

				 

        }

    });  

    $("#listRefnos").val('');  

  }

 }

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
sorry the above was incorrect, i am using this to call the function
<a href="javascript:viewList();" class="button" id="viewList">
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
You need to double check your server script. Currently, list_proxy.asp is returning this:
 <font face="Arial" size=2>
<p>Microsoft VBScript runtime </font> <font face="Arial" size=2>error '800a0005'</font>
<p><font face="Arial" size=2>Invalid procedure call or argument: 'left'</font><p>
<font face="Arial" size=2>/artism/admin/list_proxy.asp</font><font face="Arial" size=2>, line 24</font>

which is a server-side error.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Author Comment

by:newbie27
Comment Utility
Hello Hielo,
This error has been fixed but I am not able to assign the result IDs to the query ....

getListRefs();                 --> this actually does ajax call to list_proxy.asp and i see the results back
var sRefNos = $("#listRefnos").val();  --> however i am not able to pick them from here making sRefNos empty ...

thanks


there is another question needs your help ....
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23471788.html
 

 function getListRefs(sListname)

 {

 $.ajax({

 type: "POST",

 url: "list_builder.asp",

 data: "action=results&listname="+sListname,

 success: function(msg){

 $("#listRefnos").val( msg );

 }

});

Open in new window

0
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
Comment Utility
The problem is that these two are called immediately in succession, one after the other:
getListRefs();
var sRefNos = $("#listRefnos").val();

getListRefs() makes an asynchronous ajax request. So, it will take some time before the request completes. Hence this:
success: function(msg){
 $("#listRefnos").val( msg );
 }

will assign msg to #listRefnos AFTER the request has completed, but the browser executes  var sRefNos = $("#listRefnos").val();  before the request is completed.

You need to call getListRefs and then provide a callback function that will then do the remaining steps AFTER the request has completed. So, you need to
modify getListRefs and viewList
create a new call back function =>viewListCallBack
 function getListRefs(sListname,callBackFunc)
 

{
 

	$.ajax({
 

	  type: "POST",
 

	  url: "list_builder.asp",
 

	  data: "action=results&listname="+sListname,
 

	  success: function(msg){

		$("#listRefnos").val( msg );		

		callBackFunc();

	  }
 

	});
 

}
 
 

function viewList(){

    

  var sListname = $("#drpLists").val();

  

  if(sListname == 0 || sListname == "new"){  

    alert('Please select a list');

  }else{

   

	getListRefs(sListname,viewListCallBack);		

 

   

  }

 }

 

function viewListCallBack()

{

	var sRefNumbers = $("#listRefnos").val();

alert( sRefNumbers)

	$('#defaultResults').hide();

    var sViewQuery = "SF1=keyword&ST1="+sRefNumbers; 

    

	listViewer("#listDisplay1",sViewQuery);
 

}

Open in new window

0
 
LVL 8

Author Comment

by:newbie27
Comment Utility
hello hielo,
i have modified the scrpt as per your suggestion above but is giving me an error, at first it just gave me the currect number of result ids but did not update the flexigrid data ....
please can you look into this ...
thanks

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_23486091.html
0
 
LVL 8

Author Closing Comment

by:newbie27
Comment Utility
thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now