Changeset 494
- Timestamp:
- May 28, 2010, 2:15:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r484 r494 131 131 132 132 // strip the button part to only leave the Ajax call 133 button = button.replaceFirst(/<[^\"]* \"jQuery.ajax/, 'jQuery.ajax')133 button = button.replaceFirst(/<[^\"]*onclick=\"/, '') 134 134 button = button.replaceFirst(/return false.*/, '') 135 135 … … 194 194 195 195 // render new body content 196 // - this JavaScript variable is used by baseElement to workaround an IE 197 // specific issue (double submit on onchange events). The hell with IE! 198 // @see baseElement 199 out << '<script type="text/javascript">var lastRequestTime = 0;</script>' 196 200 out << render(template: "/wizard/common/tabs") 197 201 out << '<div class="content">' … … 211 215 println ".rendering [" + inputElement + "] with name [" + attrs.get('name') + "] and value [" + ((attrs.value) ? attrs.get('value').toString() : "-") + "]" 212 216 // work variables 217 def internetExplorer = (request.getHeader("User-Agent") =~ /MSIE/) 213 218 def description = attrs.remove('description') 214 219 def addExampleElement = attrs.remove('addExampleElement') … … 222 227 223 228 // add onChange AjaxSubmit javascript 224 attrs.onChange += ajaxSubmitJs( 225 [ 226 functionName: ajaxOnChange, 227 url: attrs.get('url'), 228 update: attrs.get('update'), 229 afterSuccess: attrs.get('afterSuccess') 230 ], 231 '' 232 ) 229 if (internetExplorer) { 230 // - somehow IE submits these onchanges twice which messes up some parts of the wizard 231 // (especially the events page). In order to bypass this issue I have introduced an 232 // if statement utilizing the 'before' and 'after' functionality of the submitToRemote 233 // function. This check expects lastRequestTime to be in the global Javascript scope, 234 // (@see pageContent) and calculates the time difference in miliseconds between two 235 // onChange executions. If this is more than 100 miliseconds the request is executed, 236 // otherwise it will be ignored... --> 20100527 - Jeroen Wesbeek 237 attrs.onChange += ajaxSubmitJs( 238 [ 239 before: "var execute=true;try { var currentTime=new Date().getTime();execute = ((currentTime-lastRequestTime) > 100);lastRequestTime=currentTime; } catch (e) {};if (execute) { 1", 240 after: "}", 241 functionName: ajaxOnChange, 242 url: attrs.get('url'), 243 update: attrs.get('update'), 244 afterSuccess: attrs.get('afterSuccess') 245 ], 246 '' 247 ) 248 } else { 249 // this another W3C browser that actually behaves as expected... damn you IE, DAMN YOU! 250 attrs.onChange += ajaxSubmitJs( 251 [ 252 functionName: ajaxOnChange, 253 url: attrs.get('url'), 254 update: attrs.get('update'), 255 afterSuccess: attrs.get('afterSuccess') 256 ], 257 '' 258 ) 259 } 233 260 } 234 261
Note: See TracChangeset
for help on using the changeset viewer.