<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pavel Chuchuva &#187; jquery</title>
	<atom:link href="http://chuchuva.com/pavel/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://chuchuva.com/pavel</link>
	<description>Blog about software</description>
	<lastBuildDate>Mon, 16 Jan 2012 10:02:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery BBQ plugin and Internet Explorer 7</title>
		<link>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/</link>
		<comments>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 10:40:06 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=174</guid>
		<description><![CDATA[Remember the problem with jQuery BBQ plugin in Internet Explorer 7? It&#8217;s not really a problem, just a minor glitch but let&#8217;s fix it anyway. Steps to reproduce: Open BBQ demo in Internet Explorer Click Next button few times Open &#8230; <a href="http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Remember the problem with jQuery BBQ plugin in Internet Explorer 7? It&#8217;s not really a problem, just a minor glitch but let&#8217;s fix it anyway.</p>
<p>Steps to reproduce:</p>
<ol>
<li>Open <a href="http://chuchuva.com/demo/jquery-bbq/">BBQ demo</a> in Internet Explorer</li>
<li>Click Next button few times</li>
<li>Open history menu</li>
</ol>
<p>Observe:<br />
<img class="alignnone size-full wp-image-170" src="http://chuchuva.com/pavel/images/2010/04/bbq-ie7.png" alt="" width="336" height="231" /></p>
<p>No page titles, just URLs. Definitely it would be nice to see photo numbers there.</p>
<p>First, let&#8217;s see how <a href="http://www.asual.com/jquery/address/">Asual jQuery Address</a> fix this problem:</p>
<pre><code class="prettyprint">_title = _d.title = value;
if (_juststart &#038;&#038; _frame &#038;&#038; _frame.contentWindow &#038;&#038;
    _frame.contentWindow.document) {
    _frame.contentWindow.document.title = value;
    _juststart = FALSE;
}
</code></pre>
<p>Aha! For IE7 you need to set title of the hidden iframe in addition to setting document title. So this is how you set page title:</p>
<pre><code class="prettyprint">document.title = "New title";
var iframe = $("iframe:hidden");
if (iframe.length > 0 &#038;&#038; iframe[0].contentWindow &#038;&#038; iframe[0].contentWindow.document)
  iframe[0].contentWindow.document.title = "New title";
</code></pre>
<p><a href="http://chuchuva.com/demo/jquery-bbq/fix-for-ie7.html">Updated demo</a> should work correctly in Internet Explorer 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jQuery BBQ plugin for photo gallery</title>
		<link>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/</link>
		<comments>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 11:41:59 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=167</guid>
		<description><![CDATA[Click here to view demo Let&#8217;s take previous demo and use jQuery BBQ plugin instead. Our goal is Ajax photo gallery that supports browser&#8217;s back button. We will display numbers instead of actual photos for now. $(function () { $(window).bind('hashchange', &#8230; <a href="http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://chuchuva.com/demo/jquery-bbq/">Click here to view demo</a></p>
<p>Let&#8217;s take <a href="http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/">previous demo</a> and use <a href="http://benalman.com/projects/jquery-bbq-plugin/">jQuery BBQ plugin</a> instead. Our goal is Ajax photo gallery that supports browser&#8217;s back button. We will display numbers instead of actual photos for now.</p>
<pre><code class="prettyprint">$(function ()
{
  $(window).bind('hashchange', function(e) {
    var i = parseInt(e.fragment, 10);
    if (!isNaN(i))
      switchTo(i);
  });
  $(window).trigger('hashchange');
});

function switchTo(i)
{
  if ($("#number").text() == i)
    return;
  $("#number").text(i);
  document.title = i;
  if (i > 1)
    $("#lnk_prev").attr("href", "#" + (i - 1)).removeClass("disabled");
  else
    $("#lnk_prev").removeAttr("href").addClass("disabled");
  if (i < 20)
    $("#lnk_next").attr("href", "#" + (i + 1)).removeClass("disabled");
  else
    $("#lnk_next").removeAttr("href").addClass("disabled");
}
</code></pre>
<p>Instead of handling click event we modify href attribute of the links. BBQ will fire hashchange event whenever we "navigate" to a new page. No need to prevent default processing â€“ simple!</p>
<p>One gotcha to watch out for is changing page title. If you take naive approach and simply use document.title (like I did) to set page title you won't see your titles in the history menu in Internet Explorer 7:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/bbq-ie7.png" alt="" width="336" height="231" class="alignnone size-full wp-image-170" /></p>
<p>Compare with Internet Explorer 8:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/bbq-ie8.png" alt="" width="336" height="232" class="alignnone size-full wp-image-171" /></p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Asual jQuery Address plugin for photo gallery</title>
		<link>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/</link>
		<comments>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 10:42:20 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=151</guid>
		<description><![CDATA[Click here to view demo Let&#8217;s say you want to build photo gallery. Something like this: You want to open next and previous photos without page reload, using Ajax. One problem with this is that browser&#8217;s back button stops working. &#8230; <a href="http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://chuchuva.com/demo/asual-jquery-address/">Click here to view demo</a></p>
<p>Let&#8217;s say you want to build photo gallery. Something like this:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/gallery-mockup.gif" alt="" width="270" height="251" class="alignnone size-full wp-image-153" /></p>
<p>You want to open next and previous photos without page reload, using Ajax. One problem with this is that browser&#8217;s back button stops working. Fortunately, it&#8217;s easy to fix with <a href="http://www.asual.com/jquery/address/">jQuery Address plugin</a> from Asual. I tried using this plugin and it worked very well. I&#8217;ve put together a simple <a href="http://chuchuva.com/demo/asual-jquery-address/">demo</a>.</p>
<p>For simplicity, let&#8217;s display just a number instead of actual photo:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/gallery-mockup2.gif" alt="" width="261" height="216" class="alignnone size-full wp-image-154" /></p>
<p>Every time you click right arrow the number increases; left arrow decrements the number by one. Simple! Back and forward buttons should work. Also, it would be nice to have different titles in the history:</p>
<p><img src="http://chuchuva.com/pavel/images/2010/04/browser-history.png" alt="" width="181" height="173" class="alignnone size-full wp-image-155" /></p>
<p>The code:</p>
<pre><code class="prettyprint">$(function ()
{
  $.address.strict(false);
  $.address.externalChange(function(e)
  {
    switchTo(e.value);
  });

  $("#lnk_prev").click(function(e)
  {
    e.preventDefault();
    var i = $("#number").text() * 1 - 1;
    switchTo(i);
    $.address.value(i);
  });

  $("#lnk_next").click(function(e)
  {
    e.preventDefault();
    var i = $("#number").text() * 1 + 1;
    switchTo(i);
    $.address.value(i);
  });
});

function switchTo(i)
{
  $("#number").text(i);
  $.address.title(i);
}
</code></pre>
<p>The magic happens in click handler. $.address.value method changes page address and adds browser history point. You need to cancel navigation by calling e.preventDefault() — otherwise browser would follow the link and two history entries would get created.</p>
<p><a href="http://chuchuva.com/demo/asual-jquery-address/"><img src="http://chuchuva.com/pavel/images/2010/04/gallery-demo.png" alt="" width="499" height="450" class="alignnone size-full wp-image-158" /></a></p>
<p>Note that you need to disable plugin&#8217;s strict option, otherwise it would add slash symbol immediately after hash symbol, like this: #/11.</p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

