Hi B,

I would think this is an important feature so the fact that you are
looking to do the same thing means I am not alone..  I'd like to
submit this as a feature but am still trying to figure out the state
of trigger's undocumented parameter "fn":
http://groups.google.com/group/jquery-en/browse_thread/thread/ace02e1b78894fc2/1be5003cc4cd690c#1be5003cc4cd690c


The change is trivial but you have to change both the public trigger
function and the helper function (you'll find two trigger functions in
the jquery source)..  Because I don't know where the undocumented fn
param is used, I put my new eventsParam after that:

        /* helper trigger function */
        trigger: function(type, data, elem, donative, extra, eventParams) {
                // Clone the incoming data, if any
                data = jQuery.makeArray(data || []);

                // Handle a global trigger
                if ( !elem ) {
                        // Only trigger if we've ever bound an event for it
                        if ( this.global[type] )
                                jQuery("*").add([window, 
document]).trigger(type, data);

                // Handle triggering a single element
                } else {
                        // don't do events on text and comment nodes
                        if ( elem.nodeType == 3 || elem.nodeType == 8 )
                                return undefined;

                        var val, ret, fn = jQuery.isFunction( elem[ type ] || 
null ),
                                // Check to see if we need to provide a fake 
event, or not
                                event = !data[0] || !data[0].preventDefault;

                        // Pass along a fake event
                        if ( event ){
                            if(eventParams!=null){
                                eventParams.type = type;
                                eventParams.target= elem;
                               data.unshift( this.fix(eventParams) );
                            }
                            else
                               data.unshift( this.fix({ type: type,
target: elem }) );
                       }
                        // Enforce the right trigger type
                        data[0].type = type;

                        // Trigger the event
                        if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )
                                val = jQuery.data(elem, "handle").apply( elem, 
data );

                        // Handle triggering native .onfoo handlers
                        if ( !fn && elem["on"+type] && elem["on"+type].apply( 
elem, data )
=== false )
                                val = false;

                        // Extra functions don't get the custom event object
                        if ( event )
                                data.shift();

                        // Handle triggering of extra function
                        if ( extra && jQuery.isFunction( extra ) ) {
                                // call the extra function and tack the current 
return value on
the end for possible inspection
                                ret = extra.apply( elem, val == null ? data :
data.concat( val ) );
                                // if anything is returned, give it precedence 
and have it
overwrite the previous value
                                if (ret !== undefined)
                                        val = ret;
                        }

                        // Trigger the native events (except for clicks on 
links)
                        if ( fn && donative !== false && val !== false && !
(jQuery.nodeName(elem, 'a') && type == "click") ) {
                                this.triggered = true;
                                try {
                                        elem[ type ]();
                                // prevent IE from throwing an error for some 
hidden elements
                                } catch (e) {}
                        }

                        this.triggered = false;
                }

                return val;
        },


        /* public trigger function*/
        trigger: function( type, data, fn ,eventParams) {
                return this.each(function(){
                        jQuery.event.trigger( type, data, this, true, 
fn,eventParams );
                });
        },



On Feb 4, 5:03 pm, B <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to also trigger the draggable from within a javascript
> function. If possible can you please share your source hack.
>
> Thanks
>
> On Jan 29, 2:49 pm, edwardbaafi <[EMAIL PROTECTED]> wrote:
>
> > >http://docs.jquery.com/Eventshasmousedown, mouseup, mousemove, etc
>
> > Yes, you are able to trigger these events using "trigger( type,
> > data )", but what about setting the event properties?
>
> > In my case, when an element is "draggable" and it's mousedown event
> > fires, the
> > click function in ui.mouse.js is called..  A number of properties of
> > the event, like e.which, e.target, e.srcElement, e.pageX, e.pageY are
> > needed but at least some of these properties are undefined..
>
> > Is it possible to set these properties when calling
> > trigger('mousedown') or with some other unpublished way?
>
> > Thanks,
>
> > Ed

Reply via email to