Note that there are some explanatory texts on larger screens.

plurals
  1. POloading colorbox from within AJAX content
    primarykey
    data
    text
    <p>Firstly I am very new to all forms of javascript, particularly anything remotely AJAX. That said, over the course of the last day I have managed to code a script that dynamically refreshes a single div and replaces it with the contents of a div on another page.</p> <p>The problem however is that several of my other scripts do not work in the ajax refreshed content. The most important of which being "colorbox".</p> <p>I have spent several hours this evening researching this and am seeing lot's of stuff regarding .load, .live... updating the DOM on refresh etc...etc... But to be quite honest most of it is going over my head currently and I wouldn't know where to begin in terms of integrating it with the code I currently have.</p> <p>My Ajax refresh code is as follows (My apologies if I haven't used best practice, it was my first attempt):-</p> <pre><code>$(function() { $(".artist li.artist").removeClass("artist").addClass("current_page_item"); $("#rightcolumnwrapper").append("&lt;img src='http://www.mywebsite.com/wp-content/images/ajax-loader.gif' id='ajax-loader' style='position:absolute;top:400px;left:190px;right:0px;margin-left:auto;margin-right:auto;width:100px;' /&gt;"); var $rightcolumn = $("#rightcolumn"), siteURL = "http://" + top.location.host.toString(), hash = window.location.hash, $ajaxSpinner = $("#ajax-loader"), $el, $allLinks = $("a"); $ajaxSpinner.hide(); $('a:urlInternal').live('click', function(e) { $el = $(this); if ((!$el.hasClass("comment-reply-link")) &amp;&amp; ($el.attr("id") != 'cancel-comment-reply-link')) { var path = $(this).attr('href').replace(siteURL, ''); $.address.value(path); $(".current_page_item").removeClass("current_page_item"); $allLinks.removeClass("current_link"); $el.addClass("current_link").parent().addClass("current_page_item"); return false; } e.preventDefault(); }); $.address.change(function(event) { $ajaxSpinner.fadeIn(); $rightcolumn.animate({ opacity: "0.1" }) .load(siteURL + event.value + ' #rightcolumn', function() { $ajaxSpinner.fadeOut(); $rightcolumn.animate({ opacity: "1" }); }); });}); </code></pre> <p>I was hoping someone might be kind enough to show me the sort of modifications I would need to make to the above code in order to have the colorbox load when the contents of #rightcolumn have been refreshed.</p> <p>There is also a second part to this question. My links to the pictures themselves are now also being effected by the hashtag due to the above code which will in turn prevent the images themselves from loading correctly in the colorbox I should imagine. How can I prevent these images from being effected and just have them keep the standard URL. I only want the above code to effect my internal navigation links if at all possible.</p> <p>Many thanks guys. I look forward to your replies.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload