I've been trying to create a series of drop downs that extends the inPlaceEditor class that is used in Scriptaculous and it keeps throwing up on the prototype getValue function. This code was originally for an older version of prototype and scriptaculous and was posted as a rails patch back in 2006. The code will be below this post.
It does appear as though the form never actually gets to the onSubmit action which is probably why I'm having this problem. Any help, ideas, or flat out alternative solutions would be appreciated. If you need more information by all means let me know and I can deliver. Error in Firebug: Form.Element.Serializers[method] is not a function getValue()(div)prototyp...223404303 (line 3524) handleFormSubmission()(submit )controls...223063372 (line 622) (?)()()prototyp...223404303 (line 208) [Break on this error] return Form.Element.Serializers[method] (element); In HTML: <span id="unique_date">January 1, 2008</span> <script type='text/javascript'> new Ajax.InPlaceCalendarEditor("unique_date", "#", { fieldPostCreation: false, value: '2008-01-01' } ); </script> Javascript Code: Ajax.InPlaceCalendarEditor = Class.create(); Object.extend(Ajax.InPlaceCalendarEditor.prototype, Ajax.InPlaceEditor.prototype); Object.extend(Ajax.InPlaceCalendarEditor.prototype, { createSelectBox: function(collection, value) { var selectTag = document.createElement("select"); collection.each(function(e, i) { optionTag = document.createElement("option"); optionTag.value = (e instanceof Array) ? e[0] : e; var optionName = (e instanceof Array) ? e[1] : e; if (value == optionTag.value) optionTag.selected = true; optionTag.appendChild(document.createTextNode(optionName)); selectTag.appendChild(optionTag); }.bind(this)); return selectTag; }, createCheckBox: function(value) { var labelTag = document.createElement("label"); checkTag = document.createElement("input"); checkTag.type = "checkbox"; checkTag.id = "valueCheck"; checkTag.checked = value; labelTag.appendChild(checkTag); labelTag.appendChild(document.createTextNode(' never')); return labelTag; }, createEditField: function() { if (!this.cached_Div) { var parts = this.options.value.split('-'); var theDiv = document.createElement("div"); var days = new Array(); for (var i = 1; i <= 31; i++) days[days.length] = [(i < 10) ? '0' + i : i, i]; theDiv.appendChild(this.createSelectBox(days, parts[2])); var months = [['01', 'January'], ['02', 'February'], ['03', 'March'], ['04', 'April'], ['05', 'May'], ['06', 'June'], ['07', 'July'], ['08', 'August'], ['09', 'September'], ['10', 'October'], ['11', 'November'], ['12', 'December']]; theDiv.appendChild(this.createSelectBox(months, parts[1])); var years = new Array(); for (var i = 2006; i <= 2020; i++) years[years.length] = [(i < 10) ? '0' + i : i, i]; theDiv.appendChild(this.createSelectBox(years, parts[0])); if (this.options.never) theDiv.appendChild(this.createCheckBox(parts[0] == '0000')); this.cached_Div = theDiv; } //this.editField = this.cached_Div; this._controls.editor = this.cached_Div; if (this.options.loadTextURL) this.loadExternalText(); //this.form.appendChild(this.editField); this._form.appendChild(this._controls.editor); this.options.callback = function(form, value) { return "value=" + encodeURIComponent(value); } }, onSubmit: function() { // onLoading resets these so we need to save them away for the Ajax call var form = this.form; // var value = this.editField.value; var controls = this.editField.getElementsByTagName('select'); var value = controls[2].value + '-' + controls[1].value + '-' + controls[0].value; if (this.options.never) { var check = this.editField.getElementsByTagName('input')[0]; if (check.checked) value = '0000-00-00'; } // do this first, sometimes the ajax call returns before we get a chance to switch on Saving... // which means this will actually switch on Saving... *after* we've left edit mode causing Saving... // to be displayed indefinitely this.onLoading(); if (this.options.evalScripts) { new Ajax.Request( this.url, Object.extend( { parameters: this.options.callback(form, value), onComplete: this.onComplete.bind(this), onFailure: this.onFailure.bind(this), asynchronous:true, evalScripts:true }, this.options.ajaxOptions)); } else { new Ajax.Updater( { success: this.element, // don't update on failure (this could be an option) failure: null }, this.url, Object.extend( { parameters: this.options.callback(form, value), onComplete: this.onComplete.bind(this), onFailure: this.onFailure.bind(this) }, this.options.ajaxOptions)); } // stop the event to avoid a page refresh in Safari if (arguments.length > 1) { Event.stop(arguments[0]); } return false; } }); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---