I hate to bother you with such a pedantic question, but why is this being
done with Javascript? Shouldn't this type of behavior be handled
server-side? What about users of older browsers, screen readers, or people
who choose to turn Javascript off?

Chuck Harmston
http://chuckharmston.com


On Tue, Apr 14, 2009 at 11:37 PM, Byrne Reese <byrnere...@gmail.com> wrote:

>
> First, some background:
>
> I am one of the lead contributors to the Movable Type Open Source
> project and am currently engaged in writing a jquery plugin that would
> be used on all of the blogs the platform publishes. So far I have
> successfully written a surprisingly complex plugin that works like
> this:
>
>    $('#greeting').greet( options );
>
> Which would convert:
>
>   <div id="greeting"></div>
>
> Into a message that would look like this:
>
>   Welcome Byrne! (edit profile | logout)
>
> You get the idea.
>
> The options I need to pass into the plugin is pretty substantial so I
> won't bother you with the specifics.
>
> Here is my question:
>
> I want my plugin to surface multiple event handlers like the
> following:
>
> a) $('#id').greet( { loggedOutMessage: 'Welcome back %user!
> %logout' });
>
> This is from the example above.
>
> b) $('#id').loggedIn( function(user) { $(this).show(); alert(u.name +
> ' logged in'); } );
>
> This would be invoked when a user successfully logged in and would be
> invoked whenever a login event occurred (which happens mainly via
> Ajax). One use case for this function is to selective show an element
> that would otherwise be hidden if the user was logged out.
>
> c) $('#id').loggedOut( function() { $(this).hide(); } );
>
> Similar to (b) above, but this of course would respond to a logout
> event.
>
> Ok, finally the question: I would like for all of the above use cases
> to be served by the same plugin. There is a lot of shared code between
> all three and a lot of shared config options between them.
>
> I would like to somehow initialize the system once with the same
> config options, but then subsequently invoke the loggedIn, loggedOut
> and greet functions on various elements.
>
> I guess I am just a little lost on the best way to do this and was
> wondering if there was any kind of best practice I should follow
> here.
>
> Not knowing a lot about how I *should* do it, here are some ideas I
> have for what the client code could look like:
>
> Idea 1:
>
> $.mtInit( global_options );
> $(document).ready( function(){
>  $('#greet').greet( greet_specific_options );
> });
> $('.hide_when_logged_out').loggedIn( function() { $(this).show(); } );
> $('.hide_when_logged_out').loggedOut( function() { $(this).hide
> (); } );
>
> Idea 2:
>
> $.mtInit({
>  cookiePath: 'foo',
>  cookieDomain: 'bar',
>  cookieName: 'baz',
>  onLoggedIn: function() { $('#greeting').greet(); },
>  onLoggedOut: function() { $('.hide_when_logged_out').hide(); }
> });
>
> Does anyone have any thoughts to share on the best or better way to do
> this?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to