Permalink
Browse files

Fixing scrolling bugs

  • Loading branch information...
1 parent e0bcf4b commit 16243399699ccf8899908d97c17ba8aba1b8692a @mikeymckay committed Jan 29, 2014
Showing with 51 additions and 34 deletions.
  1. +20 −14 _attachments/app/views/QuestionView.coffee
  2. +29 −18 _attachments/app/views/QuestionView.js
  3. +1 −1 _attachments/index.html
  4. +1 −1 _docs/version.json
@@ -199,21 +199,25 @@ class QuestionView extends Backbone.View
# Update the menu
Coconut.menuView.update()
+ @save()
+ @updateSkipLogic()
+ @actionOnChange(event)
else
@changedComplete = false
messageVisible = window.questionCache[targetName].find(".message").is(":visible")
- unless messageVisible
- wasValid = @validateOne
- key: targetName
- autoscroll: false
- button: "<button type='button' data-name='#{targetName}' class='validate_one'>Validate</button>"
-
- @save()
-
- @updateSkipLogic()
- @actionOnChange(event)
+# Hack by Mike to solve problem with autocomplete fields being validated before
+ _.delay =>
+ unless messageVisible
+ wasValid = @validateOne
+ key: targetName
+ autoscroll: false
+ button: "<button type='button' data-name='#{targetName}' class='validate_one'>Validate</button>"
+ @save()
+ @updateSkipLogic()
+ @actionOnChange(event)
+ @autoscroll(event) if wasValid
+ , 500
- @autoscroll(event) if wasValid and not messageVisible
onValidateOne: (event) ->
$target = $(event.target)
@@ -331,13 +335,14 @@ class QuestionView extends Backbone.View
clearTimeout @autoscrollTimer
+ # Some hacks in here to try and make it work
if event.jquery
$div = event
- name = $div.attr("data-question-name")
+ window.scrollTargetName = $div.attr("data-question-name") || $div.attr("name")
else
$target = $(event.target)
- name = $target.attr("name")
- $div = window.questionCache[name]
+ window.scrollTargetName = $target.attr("name")
+ $div = window.questionCache[window.scrollTargetName]
@$next = $div.next()
@@ -347,6 +352,7 @@ class QuestionView extends Backbone.View
@$next = @$next.next()
if @$next.is(":visible")
+ return if window.questionCache[window.scrollTargetName].find(".message").is(":visible")
$(window).on( "scroll", => $(window).off("scroll"); clearTimeout @autoscrollTimer; )
@autoscrollTimer = setTimeout(
=>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -33,7 +33,7 @@
<script type="text/javascript" src="js-libraries/jquery-1.7.2.min.js"></script>
-->
<script type="text/javascript" src="js-libraries/jquery-2.1.0.min.js"></script>
- <script type="text/javascript" src="js-libraries/jquery-migrate-1.2.1.js"></script>
+ <script type="text/javascript" src="js-libraries/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="js-libraries/underscore-min.js"></script>
<script type="text/javascript" src="js-libraries/backbone-min.js"></script>
<script type="text/javascript" src="js-libraries/jquery.couch.js"></script>
View
@@ -1 +1 @@
-{"version":"ae97a66","isApplicationDoc":true}
+{"version":"e0bcf4b","isApplicationDoc":true}

0 comments on commit 1624339

Please sign in to comment.