Skip to content

Commit

Permalink
There were alot of missing features in tank_engine.js with _replace l…
Browse files Browse the repository at this point in the history
…inks

and lists.  This should now work.
  • Loading branch information
Austin Fonacier committed Mar 29, 2009
1 parent 8a51dba commit cd964cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions assets/javascripts/tank_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,44 @@ function make_toggles() {
function() {});
}

// Let's listen to the click events of all the DOM events we care about
function init_listiners() {
// Let's keep track of all the _replace
$("a[target='_replace']").live("click",
function(event){
// prevent link from actuall clicking
event.preventDefault();
var link_elememt = $(this);
//Make the link blue
$(link_elememt).attr("selected", "progress");

$.get($(this).attr('href'), function(data){
// Turn off the ajax loading gif
$(link_elememt).removeAttr('selected');
// Append the data
$(link_elememt).parent().parent().append(data);
// Remove the the selected
$(link_elememt).parent().remove();
// Attach the HTML
$(link_elememt).parent().html(data);
});
}
);
}

// Stolen from iui. We need to pre-load the preloader image
function preloadImages()
{
var preloader = document.createElement("div");
preloader.id = "preloader";
document.body.appendChild(preloader);
}

function init() {
make_sliders();
make_toggles();
init_listiners();
preloadImages();
}

$(function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/tank_engine_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def list_element(item, target = nil, slide = true)

def append_options(list_content, options = {})
list_content = options[:top] + list_content if options[:top]
list_content += list_element(options[:more], :replace) if options[:more]
list_content += list_element(options[:more], :replace) if options[:more] && !options[:more].kind_of?(String)
list_content += content_tag(:li, options[:more]) if options[:more] && options[:more].kind_of?(String)
list_content += options[:bottom] if options[:bottom]
list_content
Expand Down

0 comments on commit cd964cd

Please sign in to comment.