<!DOCTYPE html>
<html>
<head>
<title>afBedSheet & Fanquery</title>
<script src="/pod/tales/res/jquery-1.6.1.min.js" language="javascript"></script>
<script src="/pod/sys/sys.js" language="javascript"></script>
<script src="/pod/fanquery/fanquery.js" language="javascript"></script>
<script src="/pod/afBedSheetTales/afBedSheetTales.js" language="javascript"></script>
<script>
// this global method is required to create the fanquery instance
function $makeJq(obj) {
return fan.afBedSheetTales.Jq.make(obj);
}
// instantiate and call your JS classes / methods
fan.afBedSheetTales.MyFanq.make().wotever("Alice");
</script>
</head>
<body>
Hello!
</body>
</html>
(substitute afBedSheetTales with your pod name.)
with the following classes:
using fanquery
** the idea is that Jq extends your other bespoke fanQuery plugins
@Js
class Jq : JqBase {
new make(Obj? selector, JqBase? context := null) : super(selector, context){ }
}
@Js
class MyFanq {
Void wotever(Str name) {
JqBase.ready {
Win.cur.alert("Hello ${name}!")
}
}
}
then you should get a Hello Alice! alert on page load.
Above, jquery is being served from the tales pod, but it could be served from anywhere.
SlimerDude Thu 18 Jul 2013
I was briefly looking at how best to detach Fanquery from tales and thought I'd share my initial findings.
Assuming pod resources are being served up under
/pod/... in afBedSheet 0.0.8 this would be:@Contribute { serviceType=Routes# } static Void contributeRoutes(OrderedConfig conf) { ... conf.add(Route(`/pod/***`, PodHandler#service)) ... }then if your html looks like:
<!DOCTYPE html> <html> <head> <title>afBedSheet & Fanquery</title> <script src="/pod/tales/res/jquery-1.6.1.min.js" language="javascript"></script> <script src="/pod/sys/sys.js" language="javascript"></script> <script src="/pod/fanquery/fanquery.js" language="javascript"></script> <script src="/pod/afBedSheetTales/afBedSheetTales.js" language="javascript"></script> <script> // this global method is required to create the fanquery instance function $makeJq(obj) { return fan.afBedSheetTales.Jq.make(obj); } // instantiate and call your JS classes / methods fan.afBedSheetTales.MyFanq.make().wotever("Alice"); </script> </head> <body> Hello! </body> </html>(substitute
afBedSheetTaleswith your pod name.)with the following classes:
using fanquery ** the idea is that Jq extends your other bespoke fanQuery plugins @Js class Jq : JqBase { new make(Obj? selector, JqBase? context := null) : super(selector, context){ } } @Js class MyFanq { Void wotever(Str name) { JqBase.ready { Win.cur.alert("Hello ${name}!") } } }then you should get a
Hello Alice!alert on page load.Above, jquery is being served from the tales pod, but it could be served from anywhere.