JavaScript Re-rendering Reloading Partial in Rails

I have a list of links to posts on a page. When clicked, the link triggers a lightbox with a partial showing the post.

My problem:

1.) A user interacts with the lightbox and changes information about the post (favoriting, unfavoriting).

2.) User then closes the lightbox

3.) User reopens the lightbox by clicking on the link again. Lightbox information is NOT updated with the changes the user just made.

4.) But if the user refreshes the whole page Ctrl+R and clicks on the lightbox, the lightbox will reflect the new changes.

Lightbox I am using is FancyBox.

Link to Lightbox

     <a class="fancyboxentry" rel="entries" target='_blank' href="#entryshow<%= thispost.id%>" onclick ="renderEntry<%=thispost.id%>()">
     <%= image_tag(thispost.content_2)%>
     </a>

Dummy div to hold loaded partial.

     <div id="entryshow<%= thispost.id %>"> </div>

renderEntry function:

    <script>
    function renderEntry<%= thispost.id%>() {
    $('#entryshow<%= thispost.id%>').html("<%=escape_javascript(render(:partial => 'posts/show', :locals => {:id => thispost.id})).html_safe %>");}
    </script>

How can I get the partial to re-render, which means pulling new information from the database (checking whether it is favorited, new comments, etc) EVERY time the link is clicked? My current links seem to just cache old information until the page is refreshed.

Answer:1

I have the following Object: var obj = { "2014": {}, "2013": {}, "2012": {}, "description": null, "image": null }, objKeys = Object.keys(obj); //objKeys contains [ "2014", "2013", "2012", "...

I have the following Object: var obj = { "2014": {}, "2013": {}, "2012": {}, "description": null, "image": null }, objKeys = Object.keys(obj); //objKeys contains [ "2014", "2013", "2012", "...

I had the same problem this person: ShareThis plugin not working in FancyBox title But now I have gotten it work, except the afterShow: function(){ stButtons.locateElements(); } Where in this code ...

I had the same problem this person: ShareThis plugin not working in FancyBox title But now I have gotten it work, except the afterShow: function(){ stButtons.locateElements(); } Where in this code ...

I'm trying to group with kendo grid, but I am facing a problem with the default functionality of kendo grouping. Kendo grid groups the columns but it doesn't differ records of "USA" with "usa", these ...

I'm trying to group with kendo grid, but I am facing a problem with the default functionality of kendo grouping. Kendo grid groups the columns but it doesn't differ records of "USA" with "usa", these ...

  1. kendo grid grouping angular
  2. kendo grid grouping mvc
  3. kendo grid grouping collapse all
  4. kendo grid grouping jquery
  5. kendo grid grouping demo
  6. kendo grid grouping example
  7. kendo grid grouping and paging
  8. kendo grid grouping header template
  9. kendo grid grouping server side
  10. kendo grid grouping sort order
  11. kendo grid grouping
  12. kendo grid grouping template
  13. kendo grid grouping not working
  14. kendo grid grouping aggregate
  15. kendo grid grouping row template
  16. kendo grid grouping event
  17. kendo grid grouping header
  18. kendo grid grouping order
  19. kendo grid grouping asp.net mvc
  20. kendo grid grouping sort

I have always seen code like this: (function(){ //code here })(); How does this code work? Which function receives which parameters? (function(factory){ //code here }(function($){ //other ...

I have always seen code like this: (function(){ //code here })(); How does this code work? Which function receives which parameters? (function(factory){ //code here }(function($){ //other ...