Re: [Xsltforms-support] XSLTForms w/ jQuery & Any+Time(TM)
Brought to you by:
alain-couthures
From: Stephen C. <Ste...@ut...> - 2010-03-16 22:55:23
|
Hi Andrew, Thanks for this, much appreciated. I should be able to have a go with it in the next few days. Looking at what you have suggested it might be worth taking a look at the exsltforms (http://sourceforge.net/projects/extxsltforms) project on source-forge to see how their 'extensions' to XSLTForms are included (I allows you to include CKEditor for example), but jquery might be the difference. In terms of useability I think that AnyTime is an improvement over the current Calendar pop-up in XSLTforms but there is one problem in that it does not allow you to interact with the date-time input control, particularly to paste a value. For general use how you have it setup is fine but in my case where people may be copying data from another electronic document into a web-form this will not work. No doubt I can change this arrangement fairly easily in the AnyTime javascript. The way date validation is done currently in XSLTForms has problems for me, so if a short term solution is available using *AnyTime.Converter that would be good as well. * Andrew M. Andrews III wrote: > Hi Stephen, > > I saw your post about trying to use Any+Time(TM) with XSLTForms: > http://tinyurl.com/yl7oakx > > I want to let you know that I got jQuery and AnyTime.widget to work > with the XSLTForms spreadsheet.xml demo, but it required a bit of a > hack. First, I changed my library to be compatible with jQuery's > noConflict() method. You can get the new version 3.1012 here: > > http://www.ama3.com/anytime/ > > Next, I determined that you have to add the necessary JavaScript code > to the page in a very round-about way, I think because there is a > delay in how the browsers execute scripts after an XML/XSLT > transformation. Basically, the solution I found was to use a timeout > to delay and synchronize the load and execution of jquery.js, > anytime.js and a short script containing jQuery.noConflict() and > AnyTime.widget() calls. For example, if you create an <input> that > you want to manage using my library such as this: > > <input type="text" id="AnyTimeDemo" /> > > Then place the following script just before the closing </body> tag in > your XML document: > > <script type="text/javascript"> > setTimeout( > function() > { > var atwx = document.createElement("script"); > atwx.type = "text/javascript"; > atwx.src = "jquery.js"; > document.getElementsByTagName("head")[0].appendChild(atwx); > setTimeout( > function() > { > atwx = document.createElement("script"); > atwx.type = "text/javascript"; > atwx.src = "anytime.js"; > document.getElementsByTagName("head")[0].appendChild(atwx); > setTimeout( > function() > { > atwx = document.createElement("script"); > atwx.type = "text/javascript"; > var code = > 'jQuery.noConflict();AnyTime.widget("AnyTimeDemo");'; > if ( atwx.canHaveChildren ) > atwx.appendChild(document.createTextNode(code)); > else > atwx.text = code; > > document.getElementsByTagName("head")[0].appendChild(atwx); > }, 100 ); > }, 100 ); > }, 100 ); > </script> > > A few changes you'll have to make to your version: > > (1) If jquery.js and anytime.js do not reside in the current > directory, be sure to use the appropriate path in the lines that > assign atwx.src! > > (2) If your date/time field does not have the ID "AnyTimeDemo", be > sure to change it in the line that calls AnyTime.widget(). You can > also modify the code string to create additional widgets and pass > parameters to them. > > (3) You might have to increase the delays on the timeouts from 100 > miliseconds to something longer, but try not to make them longer than > necessary or it will delay how long it takes the widgets to appear. > > (4) If you want, you can of course put the calls to > jQuery.noConflict() and AnyTime.widget() into a separate script file, > and load it the same way as jquery.js and anytime.js. In fact, doing > so would probably be a Good Idea (TM). ;-) > > Please give it a try, and let me know if it does or doesn't work for > you. If you have any problems, feel free to send me the URL of your > dev/test/demo server where I can see what's going wrong, or send me > the appropriate files and I will take a look at them on my own machine. > > I look forward to hearing from you. > > Peace, > Andrew > > -- Regards Stephen Cameron Data Programmer Integrated Marine Observing System (IMOS) eMarine Information Infrastructure Project University of Tasmania, Private Bag 21, Hobart, TAS 7001, Australia Tel: +61 3 6226 8507 Fax: +61 3 6226 2997 Email: ste...@ut... URL: http://www.imos.org.au/eMII.html |