02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

};<br />

}<br />

{<br />

}<br />

event.preventDefault();<br />

// Removes the active class from all links<br />

$("a").removeClass("active");<br />

// Fades out the modal window, then removes<br />

// it from the DOM entirely<br />

$(".modal-window")<br />

.fadeOut("slow", function() {<br />

$(this).remove();<br />

}<br />

);<br />

CHAPTER 7 ■ ENHANCING THE USER INTERFACE WITH JQUERY<br />

Next, you need to modify the callback function that fires on a successful execution of $.ajax() when<br />

clicking an event title to call fx.boxin; you do so <strong>by</strong> adding the line of bold code in the listing that<br />

follows:<br />

// Pulls up events in a modal window<br />

$("li>a").live("click", function(event){<br />

// Stops the link from loading view.php<br />

event.preventDefault();<br />

// Adds an "active" class to the link<br />

$(this).addClass("active");<br />

// Gets the query string from the link href<br />

var data = $(this)<br />

.attr("href")<br />

.replace(/.+?\?(.*)$/, "$1"),<br />

// Checks if the modal window exists <strong>and</strong><br />

// selects it, or creates a new one<br />

modal = fx.initModal();<br />

// Creates a button to close the window<br />

$("")<br />

.attr("href", "#")<br />

.addClass("modal-close-btn")<br />

.html("&times;")<br />

.click(function(event){<br />

// Removes modal window<br />

fx.boxout(event);<br />

})<br />

.appendTo(modal);<br />

259

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!