i'm also trying to add a widget to external websites that will allows partners to add one line of html on to a website page to include the widget. using jonathanpg's basic concept, i am able to get the widget to show up on the external webpage. (right now i'm actually this on localhost, but the idea stays the same)
this is the one-line of code inserted to the external webpage (technically, it's not 1 line, since i include some js libraries too).
<script src='http://localhost:3000/browse/bar/1' type='text/javascript'></script>
there's some business logic processing, but here are the lines in the controller action browse/bar that adds the js to the external page.
a = escape_javascript(render_to_string(:partial => 'browse/restaurant_bar').delete!("\n"))
render(:text => "document.write('" + a + "');")where it fails, however, is when i use the widget to go back to the server and retrieve new information. at this point, i'm just trying to get a <div id="results"> tag to be updated when the form_remote_tag is submitted. here is the code from the restaurant_bar partial that i'm inserting into the external webpage:
<div id="results">
Replace me
</div>
<% form_remote_tag :url => 'http://localhost:3000/browse/update/1' do %>
Fill in your info:
Date: <%= select_month @r.datetime.month %> <%= select_day @reservation.datetime.day %>
Time: <%= select_hour @reservation.datetime.hour %>
<p><%= submit_tag 'Check' %></p>
<% end %>
all that browse/update doesn't do anything right now, though i have tried sticking in an explicit rendering of the rjs call:
here is the update.rjs template:
page.replace_html 'results', '<b>f you</b>'
when i submit from the form_remote_tag that i inserted into the external page, i get redirected to browse/update and this is displayed (as html).
try { Element.update("res_search_results", "<b>f you</b>"); }
catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"res_search_results\", \"<b>f you</b>\");'); throw e }everything works fine if i just make the partial into a regular view and then submit the form_remote_tag from there. that leads me to believe that there's something going on with the javascript that's inserted into the browser. i used firebug to compare the ajax request form that was generated and it looks identical to what is generated when i copy the partial into a view. what am i not understanding?
sorry, for the long post. any help would be greatly appreciated.
-h