Last active
August 29, 2015 14:21
-
-
Save maier-stefan/bf8be8cfc866a4e82083 to your computer and use it in GitHub Desktop.
ajax call rendering partial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def blacklisted_publishers | |
@campaigns = Campaign.joins(:campaign_publishers).where(:campaign_publishers => {blacklisted: true, blacklisted_on_publisher_network: false}).group(:campaign_id) | |
end | |
def manipulate_blacklisted_publishers | |
@campaigns = Campaign.joins(:campaign_publishers).where(:campaign_publishers => {blacklisted: true, blacklisted_on_publisher_network: false}).group(:campaign_id) | |
if params[:publisher_network_id].present? | |
@publisher_network = PublisherNetwork.find(params[:publisher_network_id]) | |
@campaigns = @campaigns.where(publisher_network_id: @publisher_network.id) | |
end | |
if params[:is_active] == "1" | |
@campaigns = @campaigns.where('campaign_status_on_publisher_network_id != ?', CampaignStatus.paused.id) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// it is acctually a js.erb file | |
$('#accordion').html("<%= j render(partial: 'blacklisted_table', locals: {campaigns: @campaigns}) %>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get 'dashboards/blacklisted_publishers', to: 'dashboards#blacklisted_publishers', as: 'dashboards_blacklisted_publishers' | |
get 'dashboards/manipulate_blacklisted_publishers/:publisher_network_id', to: 'dashboards#manipulate_blacklisted_publishers', as: 'manipulate_blacklisted_publishers_dashboards' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
campaign_publishers GET /campaign_publishers(.:format) campaign_publishers#index | |
POST /campaign_publishers(.:format) campaign_publishers#create | |
new_campaign_publisher GET /campaign_publishers/new(.:format) campaign_publishers#new | |
edit_campaign_publisher GET /campaign_publishers/:id/edit(.:format) campaign_publishers#edit | |
campaign_publisher GET /campaign_publishers/:id(.:format) campaign_publishers#show | |
PATCH /campaign_publishers/:id(.:format) campaign_publishers#update | |
PUT /campaign_publishers/:id(.:format) campaign_publishers#update | |
DELETE /campaign_publishers/:id(.:format) campaign_publishers#destroy | |
publishers GET /publishers(.:format) publishers#index | |
POST /publishers(.:format) publishers#create | |
new_publisher GET /publishers/new(.:format) publishers#new | |
edit_publisher GET /publishers/:id/edit(.:format) publishers#edit | |
publisher GET /publishers/:id(.:format) publishers#show | |
PATCH /publishers/:id(.:format) publishers#update | |
PUT /publishers/:id(.:format) publishers#update | |
DELETE /publishers/:id(.:format) publishers#destroy | |
campaign_publishers_unblacklist GET /campaign_publishers/unblacklist/:id(.:format) campaign_publishers#unblacklist | |
campaign_publishers_blacklist_on_publisher_network GET /campaign_publishers/blacklist_on_publisher_network/:id(.:format) campaign_publishers#blacklist_on_publisher_network | |
blacklisting_campaign_publishers GET /campaign_publishers/blacklisting/:campaign_id(.:format) campaign_publishers#blacklisting | |
dashboards_blacklisted_publishers GET /dashboards/blacklisted_publishers(.:format) dashboards#blacklisted_publishers | |
manipulate_blacklisted_publishers_dashboards GET /dashboards/manipulate_blacklisted_publishers/:publisher_network_id(.:format) dashboards#manipulate_blacklisted_publishers | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// it is actually a js.erb file | |
var ready; | |
ready = function() { | |
$('#publisher_network_id').change(function() { | |
$.ajax({ | |
type: 'GET', | |
url: manipulate_blacklisted_publishers_dashboards_path($('#publisher_network_id').val()), | |
data: { | |
publisher_network_id : $('#publisher_network_id').val(), | |
} | |
}); | |
}); | |
}; | |
$(document).on('page:change', ready); | |
----- new ----- | |
var ready; | |
ready = function() { | |
$('#publisher_network_id').change(function() { | |
$.ajax({ | |
type: 'GET', | |
url: "<%= manipulate_blacklisted_publishers_dashboards_path() %>", | |
data: { | |
publisher_network_id : $('#publisher_network_id').val() | |
} | |
}); | |
}); | |
}; | |
$(document).on('page:change', ready); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="page-header"> | |
<h1>Review Blacklisted Publishers</h1> | |
</div> | |
<%= debug params[:is_active] %> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<div class="row"> | |
<div class="col-lg-2"> | |
<%= label_tag :publisher_network %> | |
<%= collection_select :publisher_network, :id, PublisherNetwork.all, :id, :name, include_blank:'all' %> | |
</div> | |
<div class="col-lg-2"> | |
<%= label_tag "active on publisher network" %> | |
<%= check_box_tag :active %> | |
</div> | |
</div> | |
</div> | |
</div> | |
<%= link_to "test", manipulate_blacklisted_publishers_dashboards_path(6), remote: true %> | |
<div class="panel-group" id="accordion"> | |
<%= render partial: 'blacklisted_table', locals: {campaigns: @campaigns} %> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should modify the ajax request. Like this:
Please let me know if you have any query regarding this.