forked from winton/widgets
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making dialog_link work with multiple DOM IDs and templates in one call
- Loading branch information
Winton Welsh
committed
Aug 1, 2008
1 parent
4910a36
commit f48ebd4
Showing
2 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
<% templates.each do |template| -%> | ||
<% id = template.respond_to?(:keys) ? template.keys.first : template -%> | ||
<% template = template.respond_to?(:keys) ? template[id] : template -%> | ||
$('<%= id %>').addEvent('click', function(e) { | ||
Global.dialog.render({ element: $('template_<%= template %>').render(<%= options.to_json %>) }); | ||
return false; | ||
}); | ||
<% end -%> | ||
<% urls.each do |id, url| -%> | ||
$('<%= id %>').addEvent('click', function(e) { | ||
<% case resource_type -%> | ||
<% when :url -%> | ||
Global.dialog.render({ | ||
url: this.get('href'), | ||
url: <%= url ? url.inspect : 'null' %> || this.get('href'), | ||
data: { | ||
authenticity_token: Global.authenticity_token, | ||
implementation: 'eborhood/widgets' | ||
} | ||
}); | ||
<% when :template -%> | ||
Global.dialog.render({ element: $('template_<%= id %>').render(<%= options.to_json %>) }); | ||
<% end -%> | ||
return false; | ||
}); | ||
}); | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
:id => 'dialog_link', | ||
:resource_type => :url # :template or :url | ||
#:templates => [ :id_and_template, { :dom_id_here => 'template' } ], | ||
:templates => [], | ||
#:urls => { :dom_id_here => '/some_resource' } | ||
:urls => [] | ||
} |