 
 
   render : ->
+
     this._ensureViewIsIntact()
     this.triggerMethod('before:render', this)
 
     obj = @templateContext()
-    if not this.isRendered
+    if not this._isRendered
       @$el.html(@template(obj))
-      this.isRendered = true
+    this._isRendered = true
 
-    @$el.find("ul.pagination").html(@pagingatorTemplate(obj))
+    @$el.find("ul.pagination").html(@paginatorTemplate(obj))
     this.bindUIElements()
     this.triggerMethod('render', this)
     return this
-
-
-  # afterRender : ->
-
-  #   @ui.inputSearch.val(@collection.state.filterQuery)
 
 
   searchByHash : ->


class PaginationView extends Marionette.View

  pagingatorTemplate : _.template("""
    <li class="first <% if (Pagination.currentPage == 0) { %> disabled <% } %>">
      <a><i class="fa fa-angle-double-left"></i></a>
    </li>



  initialize : (options) ->

    @options = options
    @listenToOnce(@collection, "reset", @searchByHash)
    @listenTo(@collection, "reset", @render)


  goFirst : (evt) ->

    evt?.preventDefault()
    @collection.getFirstPage()

  goLast : (evt) ->

    evt?.preventDefault()
    @collection.getLastPage()

  goBack : (evt) ->

    evt?.preventDefault()
    @collection.getPreviousPage()

  goNext : (evt) ->

    evt?.preventDefault()
    @collection.getNextPage()


  handleClickPage : (evt) ->

    evt?.preventDefault()
    page = $(evt.target).text()
    @collection.getPage(parseInt(page) - 1)

  goToPage : (page) ->

    @collection.getPage(page)


  addElement : ->

    app.vent.trigger("paginationView:addElement")


