Nate, this solution is so wonderful that I can't hide my admiration
for jQuery and jQuery team members' work. The code you provided
satisfies me in 100%, thank you for quick reply. :-)
On Feb 5, 4:46 am, Nate Cavanaugh <[EMAIL PROTECTED]> wrote:
> Hey there,
> This was one of my big issues when I started jQuery, but there is now a
> solution as of 1.1.
>
> When you bind your method to an event, you can pass in your current object,
> and still reference it in your event function.
>
> Basically, you can pass in ANY data to your event function, and you would
> reference it with e.data, instead of this.
> This will always point to the element that is firing the event, but you can
> now reference your data by passing in that data as the second parameter,
> like so: $(...selector...).bind('click', CUSTOM_DATA, function(e){})
>
> Here is how you would write your object:
> //============================
>
> var myObject = {
>
> layout: { 'align': '' },
> start: function() {
> $('form').bind('submit', this, this.buildLayout);
> },
>
> buildLayout: function(e) {
> var currentObject = e.data;
> currentObject.layout.align = $('#elem').attr('value');
> }
>
> }
>
> function initialize() {
> myObject.start();
>
> }
>
> $().ready(initialize);
>
> //============================
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/