InPlaceEditor invoke createEditField method for creating its textField
element.
So you can instantiate InPlaceEditor and override the
createEditField() method
with something like this:
var editor = new Ajax.InPlaceEditor('editme', '#');
Object.extend(editor, {
_createEditField: editor.createEditField,
createEditField: function() {
this._createEditField();
new Autocompleter.Local(this.editField, 'band_list', ['ABBA',
'AC/DC', 'Aerosmith', 'America'], {});
}
});
On Jul 15, 5:13 am, Takanori Ishikawa <takanori.ishik...@gmail.com>
wrote:
My javascript error (in firefox) is
Error: this.element has no properties
Source File: /javascript/scriptaculous/controls.js
Line: 59
// add in the inplaceeditor for the name field
var editor=new Ajax.InPlaceEditor('name' + hoursId,'changeHour.php',{
okButton:false,
submitOnBlur:true,
formId:'ajaxForm',
callback:function(form,value){
var request="hoursId=" + hoursId + "&which=name&username=" + value;
return request;
},
});
Object.extend(editor, {
_createEditField: editor.createEditField,
createEditField: function() {
this._createEditField();
new Autocompleter.Local(this.editField.id,'name' + hoursId,
'employeeSuggestion.php',{
'minChars':1,
});
}
});
Hang on a minute: if your editor field didn't have an ID, you wouldn't
be able to bind an IPE on it. In your code, it does have an ID: 'name'
+ hoursId, it appears...
So you could very well bind your AC over it. Do note, however, that you
may end up having conflictual key bindings between IPE and AC. e.g. Esc
and Return are used by both, so there's no telling how it would react
then...
This is the ID for the div that the IPE will appear over. The problem
is that the IPE's input field does not have an ID that I can use while
using Takanori Ishikawa's suggestion.
Autocompleter constructor just uses $() function for lookup element.
So it's OK to pass element itself as first parameter.
createEditField: function() {
this._createEditField();
new Autocompleter.Local(this.editField, ...);
This isn't working either, but there are no javascript errors.
Could it be a problem with the page I'm calling on the autocompleter?
I have the php code below, followed by the JS
<?
// employeeSuggestion.php
$tmp="<ul><li>ddddddddd</li></ul>";
print $tmp;
?>
// add in the inplaceeditor for the name field
var editor=new Ajax.InPlaceEditor('name' + hoursId,'changeHour.php',{
okButton:false,
submitOnBlur:true,
formId:'ajaxForm',
callback:function(form,value){
var request="hoursId=" + hoursId + "&which=name&username=" + value;
return request;
},
});
Object.extend(editor, {
_createEditField: editor.createEditField,
createEditField: function() {
this._createEditField();
new Autocompleter.Local(this.editField,'name' + hoursId,
var editor=new Ajax.InPlaceEditor('name' + hoursId,'changeHour.php',{
okButton:false,
submitOnBlur:true,
formId:'ajaxForm',
callback:function(form,value){
var request="hoursId=" + hoursId + "&which=name&username=" + value;
return request;
},
});
Object.extend(editor, {
_createEditField: editor.createEditField,
createEditField: function() {
this._createEditField();
new Ajax.Autocompleter(this.editField,'name' + hoursId,