I am trying to call javascript from Xform. Please let me know what wrong I am doing.
Inside my head tag I have code for javascript. <script type="text/javascript"> var deleteItem= function() { alert('Hi') ; } </script>Inside by body tag I m calling the javascript. <xf:trigger id="delete" xmlns="http://www.w3.org/1999/xhtml"> <xf:label>Delete Item</xf:label> <xf:load ev:event="DOMActivate" resource="javascript:deleteItem()"/> </xf:trigger> Page load without any error. But while clicking on Delete Item button it gives me Javascript error "Object Expected at line 1. |
Administrator
|
I tried this and it works for me. See this running example:
-Erik
On Mon, Feb 7, 2011 at 7:09 AM, amittelang <[hidden email]> wrote:
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Eric,
Thanks for the reply.After removing <XHTML:HTML> and <HHTML:HEAD> and simply calling it by <HTML> and <HEAD> it calling Javascript. But if I go to read the XForm Model and its instances its giving me null. My code is like below: <xforms:model id="auctionItems" xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"> <xforms:instance id="auctions" src="oxf:/apps/xforms-hello/auctions.xml" xmlns=""/> </xforms:model> <script type="text/javascript"> var testJS= function() { var model = document.getElementById("auctionItems"); var instance = model.getInstanceDocument("auctions");//here it gives null as model is coming as null.So 2nd line is given me null and Javascript error. } </script>If from Javascript I can not read Model and its instances then there is no mean to use it in XForm. You can check the link http://www.ibm.com/developerworks/xml/library/x-xformsjavascript/ where such code is exists and according to them its working but its not working for me. |
In reply to this post by Erik Bruchez
Hello Erik Bruchez,
if i want to populated the model/instance data into javascript function,what i do? Please give ma any suitable soution Thanks Suryaprakash
Thanks,
Suryaprakash Raghuwanshi
------------------------------------------------------------------
Before printing, think about the environment
|
Hi Erik,
Thanks for your response and link to the solution. Just a bit more on this i want to pass parameter to the javascript function and the data the need to be passed is stored as an element in the some instance in the xform. so somehow i need to pass the element data from one instance as an parameter to the javascript function. Do i need to look to the xforms variables. How variables will be assined from the xform instance element . Thanks, Hasan
Regards,
Hasan |
Administrator
|
Hasan,
You could try with an AVT (the curly brackets): <xforms:load resource="javascript:deleteItem('{instance('foo')/my/param}')"/> -Erik On Wed, Apr 27, 2011 at 10:10 PM, Hasan <[hidden email]> wrote: > Hi Erik, > > Thanks for your response and link to the solution. Just a bit more on this i > want to pass parameter to the javascript function and the data the need to > be passed is stored as an element in the some instance in the xform. so > somehow i need to pass the element data from one instance as an parameter to > the javascript function. > > Do i need to look to the xforms variables. How variables will be assined > from the xform instance element . > > > Thanks, > Hasan > > ----- > Hasan > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Unable-to-call-javascript-from-XForm-tp3264298p3480158.html > Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com. > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |