Nick Manning
Nick Manning

Reputation: 2989

How do I access the "options" of a JQuery function?

JQuery functions often accept an "options" parameter, which is in the form of a JSON object. For example, taken from the JQuery website:

$('#book').animate({
    opacity: 0.25,
    left: '+=50',
    height: 'toggle'});

Is there any way to access these "options" outside of the JSON object? Furthermore, is there any way to change the properties of the JSON object from outside of the function?

For example, say I have a draggable element and I want to change the "grid" from [1,1] to [20,20] mid-drag. I know that it may be possible to work around this issue by completely reattaching a new draggable function to the element with a completely new JSON object but my question is--can I change these options without attaching a new .draggable() function.

Thanks!

Upvotes: 0

Views: 52

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 219936

You should use draggable's option API to update any of the options after the draggable instance has already been created:

$('#book').draggable('option', 'grid', [20, 20]);

Upvotes: 2

Related Questions