Question

I had a previous question that touched this topic (Rails: how to get value from another field when executing an onchange remote function in textfield), but then I dugg a little deeper and realized that my problem is the datetime_select method.

I have a textfield with onchange. In the onchange I need to get the value of a datetime_select field to pass as a parameter when making the ajax call to my controller. The first thing to note is that a datetime_select is actually composed of five dropdowns (year, month, day, hour and minute), so I need to get the values of each of them separately (I presume, is there a simpler way?). But when I try to get their value with code like:

$(model + '_' + attribute + '_3i').value  

which should return the value of the "day" dropdown I get an error: "TypeError: $("model_attribute_3i").value.toS is not a function"

If I create all the dropdowns for the datetime objects manually the same call works just fine. So there seems to be some magic in the way a datetime_select is composed that prevents me from asking the value of the dropdowns. Is there any way to go around this or do I just have to recode the datetime_select functionality in my application?

Was it helpful?

Solution

Problem seems to be solved for now, problem was me being a javascript n00b... apparently I used same variable names in too many places which leaded to weird behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top