Quick Cliencide Update
A few new additions/fixes to the Clientcide libs for your enjoyment:
- Clientcide:
- New behavior filter: StickyWin.Modal – make modal layers on the fly. Works really well with AJAX-ing in the HTML.
- Updated Tabs filter to use new filter features (defaults and the like).
- Behavior:
- adding ability to set defaults for behaviors
- More-Behaviors:
- New Delegator for Fx.Reveal. Works a bit better than the Collapser Behavior in Clientcide’s repo because there’s no startup cost.
Not a lot of meat on the bone, I know, but I wanted to release it as I go. Expect more in the coming weeks.
As a side note, if any of you are using Behavior and writing filters, I’d love to hear about it. Leave a comment or drop me a line.
No TweetBacks yet. (Be the first to Tweet this post)
Follow @clientcide on twitter to get notified of new posts.
To follow me personally on twitter, follow @anutron.
September 23rd, 2011 at 8:35 am
R.e. behavior options, I believe all options must be strict JSON (though single quotes are allowed).
This would appear to prohibit nesting JSON objects within the options:
This is easy enough to work around, albeit more verbose:
A purely nice to have would be to set something like a ‘trusted’ option on the Behavior, and modify the _get* methods to only verify non-trusted stuff:
var isSecure = this.trusted || JSON.isSecure(options);
Or are you trending toward stricter JSON in general, as a pattern?
September 23rd, 2011 at 8:49 am
I’m not sure what you mean. You can absolutely have nested objects. Only functions aren’t allowed.
October 4th, 2011 at 5:21 pm
Since I learned about Behaviors and Delegators I use them all the time :)
it’s just freaking amazing :)
no more domready and dependence problems; include the behavior with packager and set data-behavior probably with some options and you are done.
just love it :)
most of the stuff is for my “own” MooTools Classes, but surely it could be some inspiration for others
https://github.com/daKmoR/mootools-stack
look at Source/Behaviors and Source/Delegators
and while I’m at it I actually have a questions if you do some ajax in the delegator you can easily reapply the behaviors as you have the “getBehavior”; but when doing some ajax in a behavior how can I apply the behaviors to the new stuff?
I currently do this on my ajax completion in the behavior (
onLoaded: function(div) { myBehavior.apply(div); }
which works but relays on a static name – so I have to stick with this name no matter what… no so nice :p any ideas?
var myBehavior=new Behavior().apply(document.body);
October 4th, 2011 at 10:34 pm
Re: applying behaviors on new content from delegators, you have two options:
1) fire the “ammendDom” event (preferred): https://github.com/anutron/more-behaviors/blob/master/Source/Delegators/Delegator.Ajax.js#L60 – this invokes this handler in Delegator: https://github.com/anutron/behavior/blob/master/Source/Delegator.js#L71
2) use api.getBehavior() to get the bound behavior instance and call it’s apply method: https://github.com/anutron/behavior/blob/master/Source/Delegator.js#L50
The former is preferred because other plugins can hook into it. Both of these are in the docs for Delegator (easy to miss; there’s a lot of documentation).
October 4th, 2011 at 10:37 pm
Nice work on that stack of Behaviors/Delegators in your github repo. Nice to see it getting used!
October 5th, 2011 at 12:52 am
I actually wanted to know howto apply behaviors inside a behavior (which does some ajax) :p
Use-case:
https://github.com/daKmoR/mootools-stack/blob/master/Source/Behaviors/Behavior.FlexBox.js#L55
thx for creating such an awesome system :)
October 5th, 2011 at 8:12 am
Ah. Looks like I don’t have this one in the docs:
https://github.com/anutron/behavior/blob/master/Source/Behavior.js#L84
api.applyFilters(element)
I’ll update docs.