Different javascript type
Closed this issue · 3 comments
GoogleCodeExporter commented
I have just started reading the DWPE book (love it btw thank you!) so
perhaps there is already a solution to this and I just didn't see it.
I wondered how one would include javascript that is not
type="text/javascript"? In particular, I am attempting to include the
Jqtouch library for the iPhone with the type="application/x-javascript".
The css loadStyles allows you to specify attributes, is there a way to do
this for the loadScripts option?
Thanks very much
Original issue reported on code.google.com by laura.hu...@gov.bc.ca
on 30 Mar 2010 at 9:43
GoogleCodeExporter commented
Hi Laura,
So glad to hear you love the book!
While it's not specifically documented in Designing with Progressive
Enhancement,
EnhanceJS allows you to specify loadScripts array items in object syntax to
specify
attributes just like you can with loadStyles.
Here's an example of specifying a particular script (jqtouch.js) in object
syntax, to
provide a custom type:
{{{
enhance({
loadScripts: ['foo.js', {src: 'jqtouch.js', type: 'application/x-javascript'}]
});
}}}
Note that when using the object instead of a string, the src attribute must be
specified
(similarly, in loadStyles, 'href' is required).
Overall, both options behave pretty much the same. You can use iecondition
parameters in both loadStyles and loadScripts if you really have to.
Hope that helps!
Let us know if you have any more questions.
-Scott
Original comment by scottj...@gmail.com
on 30 Mar 2010 at 10:06
- Changed state: Done
- Added labels: ****
- Removed labels: ****
GoogleCodeExporter commented
Thanks fantastic - thanks for your quick reply!
I had tried that originally - but of course, I used 'href' instead of 'src' so
it
wouldn't have worked ;)
Thanks again!
Original comment by laura.hu...@gov.bc.ca
on 30 Mar 2010 at 10:08
- Added labels: ****
- Removed labels: ****
GoogleCodeExporter commented
No problem.
I know I've confused src/href in those arrays before too, and then wondered why
it
wasn't working. Agh!
One of many reasons it made sense for us to implement the string option. :)
Anyway, hope that works for you!
Original comment by scottj...@gmail.com
on 30 Mar 2010 at 10:19
- Added labels: ****
- Removed labels: ****