javascript - Is it possible to update jquery tab set -


i have jquery tab set:

<div id="tabs">   <ul>     <li><a href="#tabs-1">mileage log</a></li>     <li><a href="#tabs-2">trips</a></li>   </ul>   <div id="tabs-1">something</div>   <div-id="tabs-2">something</div> </div> 

my content on tabs fires javascript code posts form data (i included code). problem tab element refresh new content can shown. there built-in way refresh tabs using "success:" option. using "location.reload();" refreshes whole page. not ideal.

thanks.

my javascript

<script> $(document).ready(function () {       //submit form add record.       $('#addmileage').submit(function (e)        {                   e.preventdefault();         $.ajax({         data: $('#addmileage').serialize(),         type:'post',         url:'actionpages/add_trip.cfm?ticketid=<cfoutput>#url.ticketid#</cfoutput>',         success: function(){         $('.success').fadein(200).show();          location.reload();         $('.error').fadeout(200).hide();             }         });     });          $('.deletemileageform').submit(function (e)        {                    e.preventdefault();         $.ajax({         data: $(this).serialize(), // **** modified line ****         type:'post',         url:'actionpages/delete_trip.cfm',         success: function () {             $('.successtab2').fadein(200).show();             location.reload();             $('.errortab2', $row).fadeout(200).hide();             }          });     });   });  </script> 

the way think achieve this, have server-side functions you're calling in ajax, return block of html inject of tab want reload. , if you're going that, you'll need put functions in cfc instead of cfm page you're calling now.

so, generate way you're doing build initial page, save generated html string , return jquery ajax call.

as bare-bones example:

$('.deletemileageform').submit(function (e)    {                e.preventdefault();     $.ajax({     data: $(this).serialize(), // **** modified line ****     type:'post',     datatype: 'json',     url:'actionpages/actions.cfc?method=deletetrip&returnformat=json',     success: function (result) {         $('.successtab2').fadein(200).show();         $('.errortab2', $row).fadeout(200).hide();         $('#tab2').html(result);         }      }); 

then on server you'll need actions.cfc remotely accessible functions:

<component>     <cffunction name="deletetrip" access="remote">         <cfset newhtml = "<h1>this new html!</h1>">         <cfreturn newhtml>     </cffunction> </component> 

i've put json format, because use json. :)

not sure how familiar cfcs, returnformats, etc. push in right direction.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -