views:

30

answers:

1

Hi,

I am using the jQuery SpinBox plugin (from http://plugins.jquery.com/project/spinbox) on some text boxes on my form. But I have come across a problem. Some of these textboxes need to have their min/max properties set dynamically when the values of other fields are changed. I have tried doing something like this:

$("#tbxDelayEndDate").spinbox({min : $("#tbxDelayStartDate").val()});

But the problem is that clicking the up/down buttons causes erratic behaviour.

How can I change the max and min properties without this happening?

EDIT: Or can anyone give me an example of one spinbox constrained by the value of another?

I don't want to have to use a different plugin.

Thanks.

James

+1  A: 

Before changing its min/max, you have to call the following statement to unbind/remove all related event/class of the spinner.Therfore, the codes that changed the min will be like this

$("#tbxDelayEndDate").spinbox("destroy");
$("#tbxDelayEndDate").spinbox({min : $("#tbxDelayStartDate").val()});

However, I find out that there is a bug in the source code of the plugin.Therefore you need to do the following first.

Search the follwing text in the source code of the plugin.

// Tidy up when spinbox('destroy') is called:
        if (options && typeof (options) === "String" && options === "destroy")

Replace the above with

 if (options && typeof (options) === "string" && options === "destroy")

"String" should be "string".

Kai
Seems to work now. Thanks.
James