+ <script type="text/javascript" charset="utf-8">
+ (function(){
+ var fform = document.getElementById('factories_form');
+ var fm = new FormManager(fform);
+ var submitButton;
+ fm.onBeforeSubmit = function(self, evt) {
+ if (submitButton)
+ self.submitButton = submitButton;
+ };
+ var id2type = /(^[^\.]+)\.id:record$/;
+ function trackFocus(evt) {
+ var input = getTargetedObject(evt);
+ var matches = id2type.exec(input.name);
+ if (matches && matches.length == 2)
+ submitButton = fform.elements[matches[1] + '.type:record'];
+ }
+ var e;
+ for (var i = 0 ; i < fform.elements.length ; i++) {
+ e = fform.elements[i];
+ if (e.type==='text')
+ addListener(e, 'focus', trackFocus);
+ }
+ }());
+ </script>