javascript - Attaching a callback to html generated by JSF - Primefaces -


i've got primefaces command button need add callback in jquery on document.ready. i've been trying reference existing function , call in new function wrote:

var existingfunction = jquery("[id~='submit']").live("click"); jquery("[id~='submit']").live("click", function(){     existingfunction();     alert('test');     updatecontrolpanel(buildcontrolpanelurl(geturlvars())); }); 

it seems simple enough me reason not work. when load page , click submit button doesn't reach alert.

i've checked error console , found it's throwing following errors:

((f.event.special[s.origtype] || {}).handle || s.handler).apply not function 

there existing jquery functions on page did not write i'd make sure error not related way i'm approaching this.

i'm using tomcat 6 older version of jquery (1.3 or 1.4 ).

thanks , let me know if guys need more info.

edit

i've put example of i'm trying on js fiddle: http://jsfiddle.net/ansxh/2/

here further clarification: i've built button project in jsf 2.0 (myfaces) using latest primefaces component library. i've taken button , embedded existing web page. button submits form , calls javascript function show result on page after ajax request complete. works when embed button onto page need update on client side after button calls function. that's why i'm looking @ adding callback existing onclick function.

as side note, because i'm using primefaces can attach javascript function run after ajax request complete. plan b try , access function , somehow override it.

edit part 2 here generated control primefaces:

<button   id="topsaveform:submittop"  name="topsaveform:submittop"  class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"  onclick="primefaces.ab({source:'topsaveform:submittop',process:'topsaveform oeimeasurementstable',update:'errormessages submittedpopup',onstart:function(cfg){jquery('#loadingbar').show('fast');;},oncomplete:function(xhr,status,args){postsubmit();;}});return false;"   type="submit">    <span class="ui-button-text">save</span> </button> 

did try making original function die (ref)?

jquery("[id~='submit']").die("click"); jquery("[id~='submit']").live("click", function(){     alert('test');     updatecontrolpanel(buildcontrolpanelurl(geturlvars())); }); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -