1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Render partial with Ajax!

Discussion in 'Ruby' started by robzdc, Apr 4, 2013.

  1. #1
    So I had some issues with an App I'm doing, I was calling an entire template...
    The problem was that when you call a template, you load all the libraries with it... its just crap.
    So I create a partial to just call the partial for every search, without the libraries or anything that I don't need.
    To do that you must specify the partial in the respond_to like this
    respond_to do |format|
          format.html { render :partial => 'partials/results' } # index.html.erb
          format.json { render json: @results, :callback => params[:callback] }
    Code (markup):
    And with jquery you just call the data
    $.get "/search/result", data, (data) ->
          $("#resultados").html data
    Code (markup):
    Maybe some of you already know that, but I'm just letting this here so maybe it can be helpful to someone else.
    robzdc, Apr 4, 2013 IP