Skip to content

Commit

Permalink
Merge pull request #791 from HubSpot/fix_search_input
Browse files Browse the repository at this point in the history
Fix search input
  • Loading branch information
Tom Petr committed Dec 18, 2015
2 parents 793e070 + 9a74044 commit c650f7d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions SingularityUI/app/views/requests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class RequestsView extends View
@currentRequests = requests

render: =>
# Save the state of the caret if the search box has already been rendered
$searchInput = $('.big-search-box')
@prevSelectionStart = $searchInput[0].selectionStart
@prevSelectionEnd = $searchInput[0].selectionEnd

# Renders the base template
# The table contents are rendered bit by bit as the user scrolls down.
context =
Expand Down Expand Up @@ -151,6 +156,10 @@ class RequestsView extends View
hide: (e) ->
@hidePopover(e)

# Reset search box caret
$searchInput = $('.big-search-box')
$searchInput[0].setSelectionRange(@prevSelectionStart, @prevSelectionEnd)

# Prepares the staged rendering and triggers the first one
renderTable: =>
return if not @$('table').length
Expand Down
9 changes: 9 additions & 0 deletions SingularityUI/app/views/tasks.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class TasksView extends View
@currentTasks = tasks

render: =>
# Save the state of the caret if the search box has already been rendered
$searchInput = $('.big-search-box')
@prevSelectionStart = $searchInput[0].selectionStart
@prevSelectionEnd = $searchInput[0].selectionEnd

# Renders the base template
# The table contents are rendered bit by bit as the user scrolls down.
context =
Expand All @@ -93,6 +98,10 @@ class TasksView extends View

super.afterRender()

# Reset search box caret
$searchInput = $('.big-search-box')
$searchInput[0].setSelectionRange(@prevSelectionStart, @prevSelectionEnd)

# Prepares the staged rendering and triggers the first one
renderTable: =>
return if not @$('table').length
Expand Down
2 changes: 1 addition & 1 deletion SingularityUI/app/views/view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class View extends Backbone.View

afterRender: ->
Sortable.init()

# Paginate client side collections
$('table.paginated:not([id])').DataTable
ordering: false
Expand Down

0 comments on commit c650f7d

Please sign in to comment.