|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
xi:include, widget, or something else?I have some static code that I want to include in a few different pages. The code basically sets up a modal window to display information, which is fetched by ajax all using jquery. Here's the xhtml part: <div class="jqmWindow" id="rinfo"> Please wait... <img src="inc/busy.gif" alt="loading" /> </div> Notice there are no variables or anything in the xhtml part. And here's the part from the header... <script src="http://www.google.com/jsapi" /> <script>google.load("jquery", "1.2");</script> <script src="/static/javascript/o/jqModal.js" /> <link rel="StyleSheet" href="/static/css/o/jqModal.css" type="text/ css" /> <script> $().ready(function() { $('#rinfo').jqm({ajax: '@href', trigger: 'a.rinfo_link'}); }); </script> Now I'm wondering whether I'm better off: a) cut and pasting this into the pages I want to use this b) making a TurboGears widget c) using one or more xi:includes d) something else This is complicated by the fact that some of the pages will be using jquery (loaded by the Google js api) for other stuff, and some won't. Obviously I don't want to load anything twice....but maybe the Google js api is smart enough not too...) Also some pages will have some other stuff that needs to go into the $ ().ready part. I'm obviously not (yet) a javascript expert... :( Any thoughts? Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: xi:include, widget, or something else?samslists@... schrieb: > I have some static code that I want to include in a few different > pages. The code basically sets up a modal window to display > information, which is fetched by ajax all using jquery. > > Here's the xhtml part: > > <div class="jqmWindow" id="rinfo"> > Please wait... <img src="inc/busy.gif" alt="loading" /> > </div> > > Notice there are no variables or anything in the xhtml part. > > And here's the part from the header... > > <script src="http://www.google.com/jsapi" /> > <script>google.load("jquery", "1.2");</script> > <script src="/static/javascript/o/jqModal.js" /> > <link rel="StyleSheet" href="/static/css/o/jqModal.css" type="text/ > css" /> > <script> > $().ready(function() { > $('#rinfo').jqm({ajax: '@href', trigger: 'a.rinfo_link'}); > }); > </script> > > Now I'm wondering whether I'm better off: > > a) cut and pasting this into the pages I want to use this > b) making a TurboGears widget > c) using one or more xi:includes > d) something else > > This is complicated by the fact that some of the pages will be using > jquery (loaded by the Google js api) for other stuff, and some won't. > Obviously I don't want to load anything twice....but maybe the Google > js api is smart enough not too...) > > Also some pages will have some other stuff that needs to go into the $ > ().ready part. > > I'm obviously not (yet) a javascript expert... :( > > Any thoughts? TG-Widget it is. Either in the constructor you can alter self.javascript to include a parametrized JSSource, or in update_params create one, and display that in the templates. Diez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: xi:include, widget, or something else?Diez B. Roggisch schrieb: > samslists@... schrieb: >> Now I'm wondering whether I'm better off: >> >> a) cut and pasting this into the pages I want to use this >> b) making a TurboGears widget >> c) using one or more xi:includes >> d) something else >> >> This is complicated by the fact that some of the pages will be using >> jquery (loaded by the Google js api) for other stuff, and some won't. >> Obviously I don't want to load anything twice....but maybe the Google >> js api is smart enough not too...) >> >> Any thoughts? > > TG-Widget it is. Either in the constructor you can alter self.javascript > to include a parametrized JSSource, or in update_params create one, and > display that in the templates. The problem with using widgets and loading JS libs by attaching JSLink widgets to them is that it is an all-or-nothing approach. Widgets won't detect that jsquery has already been loaded by the Google JS api, so you might end up with loading it twice, unless you build a widget wrapper for the Google JS api as well, which also declares the jsquery dependency via the same attached JSLink widget. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: xi:include, widget, or something else?On Monday 22 September 2008 19:08:05 Christopher Arndt wrote: > Diez B. Roggisch schrieb: > > samslists@... schrieb: > >> Now I'm wondering whether I'm better off: > >> > >> a) cut and pasting this into the pages I want to use this > >> b) making a TurboGears widget > >> c) using one or more xi:includes > >> d) something else > >> > >> This is complicated by the fact that some of the pages will be using > >> jquery (loaded by the Google js api) for other stuff, and some won't. > >> Obviously I don't want to load anything twice....but maybe the Google > >> js api is smart enough not too...) > >> > >> Any thoughts? > > > > TG-Widget it is. Either in the constructor you can alter self.javascript > > to include a parametrized JSSource, or in update_params create one, and > > display that in the templates. > > The problem with using widgets and loading JS libs by attaching JSLink > widgets to them is that it is an all-or-nothing approach. Widgets won't > detect that jsquery has already been loaded by the Google JS api, so you > might end up with loading it twice, unless you build a widget wrapper > for the Google JS api as well, which also declares the jsquery > dependency via the same attached JSLink widget. That assumes that the widget actually *loads* jquery at all. Who says it does? I personally would sure use custom JSLinks pointing to Google, but this is up to the OP to do so - or not. Diez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to turbogears@... To unsubscribe from this group, send email to turbogears+unsubscribe@... For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free Forum Powered by Nabble | Forum Help |