recordselect icon indicating copy to clipboard operation
recordselect copied to clipboard

RecordSelect not working upon validation errors

Open satynos opened this issue 15 years ago • 5 comments

My app uses ActiveScaffold and RecordSelect.

RecordSelect is working fine and showing the associated objects in auto-complete field while creating a new record or editing existing record. But when there is a validation error, it stops working. I reviewed the code that gets sent to the browser when there is a validation error. It has JavaScript for new RecordSelect.Single('id) but is not being executed. If I enter the same JavaScript code in the firebug console, then it is popping up the auto-complete results.

Any help is much appreciated.

-Satynos

satynos avatar Jan 29 '10 19:01 satynos

Sounds like ActiveScaffold is rewriting the form, but RecordSelect is not re-initializing.

cainlevy avatar Jan 29 '10 19:01 cainlevy

I didn't quite understand what you mean by not re-initializing. I see JavaScript code new RecordSelect.Single('some_id') in the output that is sent by the server. For some reason it's not executed by the browser. I even added console.log('test') before new RecordSelect.Single('some_id) and after, both console.log calls are executed and I can see the output in the firebug console. But the new RecordSelect.Single('some_id') is not executed.

Any feedback on how to get this to work is appreciated. Thanks in advance. -Satynos

satynos avatar Jan 29 '10 19:01 satynos

Hmm. Can you determine whether the JS is being executed before or after the HTML is rewritten? It needs to be executed afterwards so that it binds to the correct elements.

You could also try adding a console.log('...') command inside the RecordSelect code to determine whether it's running at all.

cainlevy avatar Jan 29 '10 19:01 cainlevy

Whats the best way to determine at what point JS is being executed?

Also I did add console.log('testing from RecordSelect.initialize') in RecordSelect Initialize method, and that part is being executed.

satynos avatar Jan 29 '10 19:01 satynos

Also if it helps, following is the link to the content that is sent by the browser upon validation error:

http://www.pastie.org/private/dxtyrx46whjae5vqgm5ha

satynos avatar Jan 29 '10 20:01 satynos