def update
      @page = Humpyard::Page.find(params[:id]).content_data
      
      if @page 
        unless can? :update, @page.page
          render :json => {
            :status => :failed
          }, :status => 403
          return
        end
        
        if @page.update_attributes params[:page]
          @page.title_for_url = @page.page.suggested_title_for_url
          @page.save
          render :json => {
            :status => :ok,
#            :dialog => :close,
            :replace => [
              { 
                :element => "hy-page-treeview-text-#{@page.id}",
                :content => @page.title
              }
            ],
            :flash => {
              :level => 'info',
              :content => I18n.t('humpyard_form.flashes.update_success', :model => Humpyard::Page.model_name.human)
            }
          }
        else
          render :json => {
            :status => :failed, 
            :errors => @page.errors,
            :flash => {
              :level => 'error',
              :content => I18n.t('humpyard_form.flashes.update_fail', :model => Humpyard::Page.model_name.human)
            }
          }
        end
      else
        render :json => {
          :status => :failed
        }, :status => 404
      end
      
    end
def update
      @page = Humpyard::Page.find(params[:id]).content_data
      
      if @page 
        unless can? :update, @page.page
          render :json => {
            :status => :failed
          }, :status => 403
          return
        end
        
        if @page.update_attributes params[:page]
          @page.title_for_url = @page.page.suggested_title_for_url
          @page.save
          render :json => {
            :status => :ok,
#            :dialog => :close,
            :replace => [
              { 
                :element => "hy-page-treeview-text-#{@page.id}",
                :content => @page.title
              }
            ],
            :flash => {
              :level => 'info',
              :content => I18n.t('humpyard_form.flashes.update_success', :model => Humpyard::Page.model_name.human)
            }
          }
        else
          render :json => {
            :status => :failed, 
            :errors => @page.errors,
            :flash => {
              :level => 'error',
              :content => I18n.t('humpyard_form.flashes.update_fail', :model => Humpyard::Page.model_name.human)
            }
          }
        end
      else
        render :json => {
          :status => :failed
        }, :status => 404
      end
      
    end
Update an existing page