Re: [Xsltforms-support] Change instance via JavaScript?
Brought to you by:
alain-couthures
From: C. M. Sperberg-M. <cm...@bl...> - 2011-11-09 01:56:06
|
On Nov 6, 2011, at 3:41 PM, Alain Couthures wrote: >> ... > Modifying an instance with Javascript instructions is always problematic > because of dependencies to be set for refresh. It could also be very > specific of a version of en implementation... > > Maybe the best way would be to just define an extension for submission: > instead of "http:" or "file:", "javascript:" could be used to retrieve a > string from a Javascript instruction. > > You could then externally activate a submit action for it. > > What do you think? Well, I don't know about the original poster, but I think you've just explained to me how to handle a problem I was having without a trip to the server. Thank you! However, when I try to put this idea into practice, I encounter a simple practical difficulty. I want to use Javascript to manipulate a string in the document, so I write a function called, say, manipulate_string, which takes a string as argument and returns a string as its result. I can write a submission element that specifies a call to this function as the resource, and I can even specify the argument (which I have placed in an instance document for the purpose), thus: <xf:submission id="hackstring" method="get" ref="instance('stringhack')/s" replace="text" targetref="instance('stringhack')/s" > <xf:resource value="concat('javascript:manipulate_string("', instance('stringhack')/s, '")')" /> </xf:submission> But before submission, XForms appends "?s=" and the value of the XPath expression in the 'ref' attribute, which has the effect that the Javascript call is not recognized so my function never executes. Is there a way around this problem? -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net **************************************************************** |