Javascript error?! - part II
Ben'k weer...
Ik had enige tijd geleden een vraag betreffende een Javascript error geplaatst op PHPHulp...een gedeelte daarvan is inmiddels opgelost.
Maar de complete oplossing heb ik echter nog niet.

Op de genoemde regel staat het volgende:
...ik weet echt niet wat ik nu moet doen (met ook de antwoorden van mijn vorige bericht in het achterhoofd).
Imenad een verlossend antwoord?
Ik had enige tijd geleden een vraag betreffende een Javascript error geplaatst op PHPHulp...een gedeelte daarvan is inmiddels opgelost.
Maar de complete oplossing heb ik echter nog niet.

Op de genoemde regel staat het volgende:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
32 // Initialize the accordions
33 //
34 initialize: function(container, options) {
35 if (!$(container)) {
36 throw(container+" doesn't exist!");
37 return false;
38 }
33 //
34 initialize: function(container, options) {
35 if (!$(container)) {
36 throw(container+" doesn't exist!");
37 return false;
38 }
...ik weet echt niet wat ik nu moet doen (met ook de antwoorden van mijn vorige bericht in het achterhoofd).
Imenad een verlossend antwoord?
Gewijzigd op 01/01/1970 01:00:00 door Erick Schluter
Gesponsorde koppelingen:
En als je (php-denkend) dit eens probeerd:
Dus iets minder verkort?
En $(container) lijkt mij 'onjuist', maar dat zal wel zijn omdat ik geen Javascript spreek.
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
32 // Initialize the accordions
33 //
34 initialize: function(container, options) {
35 if ($(container) == false ) {
36 throw(container+" doesn't exist!");
37 return false;
38 }
33 //
34 initialize: function(container, options) {
35 if ($(container) == false ) {
36 throw(container+" doesn't exist!");
37 return false;
38 }
Dus iets minder verkort?
En $(container) lijkt mij 'onjuist', maar dat zal wel zijn omdat ik geen Javascript spreek.
Als je de fout vertaald naar het engels kom je wel erg in de buurt van een uncaught exception...
Waarschijnlijk moet je via catch() je exceptie die je opwerpt via throw() nog afvangen...
http://www.w3schools.com/js/js_throw.asp
Waarschijnlijk moet je via catch() je exceptie die je opwerpt via throw() nog afvangen...
http://www.w3schools.com/js/js_throw.asp
Gewijzigd op 01/01/1970 01:00:00 door Rens nvt
Hey Eddy,
Jouw wijziging helpt ook niet echt...
En Rens...die W3C Schools uitleg toepassen op het volgende:
...waar doe ik dat?
Al mijn pogingen eindigen in alleen maar meer foutboodschappen...en die gaan voornamelijk over de 'syntaxis'...omdat ik niet exact weet waar ik de zg. 'catch' toe moet voegen.
Jij suggesties?
Jouw wijziging helpt ook niet echt...
En Rens...die W3C Schools uitleg toepassen op het volgende:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
if (typeof Effect == 'undefined')
throw("accordion.js requires including script.aculo.us' effects.js library!");
var accordion = Class.create();
accordion.prototype = {
//
// Setup the Variables
//
showAccordion : null,
currentAccordion : null,
duration : null,
effects : [],
animating : false,
//
// Initialize the accordions
//
initialize: function(container, options) {
if (!$(container)) {
throw(container+" doesn't exist!");
return false;
}
this.options = Object.extend({
resizeSpeed : 8,
classNames : {
toggle : 'accordion_toggle',
toggleActive : 'accordion_toggle_active',
content : 'accordion_content'
},
defaultSize : {
height : null,
width : null
},
direction : 'vertical',
onEvent : 'click'
}, options || {});
this.duration = ((11-this.options.resizeSpeed)*0.15);
var accordions = $$('#'+container+' .'+this.options.classNames.toggle);
accordions.each(function(accordion) {
Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false);
if (this.options.onEvent == 'click') {
accordion.onclick = function() {return false;};
}
if (this.options.direction == 'horizontal') {
var options = $H({width: '0px'});
} else {
var options = $H({height: '0px'});
}
options.merge({display: 'none'});
this.currentAccordion = $(accordion.next(0)).setStyle(options);
}.bind(this));
},
//
// Activate an accordion
//
activate : function(accordion) {
if (this.animating) {
return false;
}
this.effects = [];
this.currentAccordion = $(accordion.next(0));
this.currentAccordion.setStyle({
display: 'block'
});
this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);
if (this.options.direction == 'horizontal') {
this.scaling = $H({
scaleX: true,
scaleY: false
});
} else {
this.scaling = $H({
scaleX: false,
scaleY: true
});
}
if (this.currentAccordion == this.showAccordion) {
this.deactivate();
} else {
this._handleAccordion();
}
},
//
// Deactivate an active accordion
//
deactivate : function() {
var options = $H({
duration: this.duration,
scaleContent: false,
transition: Effect.Transitions.sinoidal,
queue: {
position: 'end',
scope: 'accordionAnimation'
},
scaleMode: {
originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
},
afterFinish: function() {
this.showAccordion.setStyle({
height: 'auto',
display: 'none'
});
this.showAccordion = null;
this.animating = false;
}.bind(this)
});
options.merge(this.scaling);
this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
new Effect.Scale(this.showAccordion, 0, options);
},
//
// Handle the open/close actions of the accordion
//
_handleAccordion : function() {
var options = $H({
sync: true,
scaleFrom: 0,
scaleContent: false,
transition: Effect.Transitions.sinoidal,
scaleMode: {
originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
}
});
options.merge(this.scaling);
this.effects.push(
new Effect.Scale(this.currentAccordion, 100, options)
);
if (this.showAccordion) {
this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
options = $H({
sync: true,
scaleContent: false,
transition: Effect.Transitions.sinoidal
});
options.merge(this.scaling);
this.effects.push(
new Effect.Scale(this.showAccordion, 0, options)
);
}
new Effect.Parallel(this.effects, {
duration: this.duration,
queue: {
position: 'end',
scope: 'accordionAnimation'
},
beforeStart: function() {
this.animating = true;
}.bind(this),
afterFinish: function() {
if (this.showAccordion) {
this.showAccordion.setStyle({
display: 'none'
});
}
$(this.currentAccordion).setStyle({
height: 'auto'
});
this.showAccordion = this.currentAccordion;
this.animating = false;
}.bind(this)
});
}
}
throw("accordion.js requires including script.aculo.us' effects.js library!");
var accordion = Class.create();
accordion.prototype = {
//
// Setup the Variables
//
showAccordion : null,
currentAccordion : null,
duration : null,
effects : [],
animating : false,
//
// Initialize the accordions
//
initialize: function(container, options) {
if (!$(container)) {
throw(container+" doesn't exist!");
return false;
}
this.options = Object.extend({
resizeSpeed : 8,
classNames : {
toggle : 'accordion_toggle',
toggleActive : 'accordion_toggle_active',
content : 'accordion_content'
},
defaultSize : {
height : null,
width : null
},
direction : 'vertical',
onEvent : 'click'
}, options || {});
this.duration = ((11-this.options.resizeSpeed)*0.15);
var accordions = $$('#'+container+' .'+this.options.classNames.toggle);
accordions.each(function(accordion) {
Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false);
if (this.options.onEvent == 'click') {
accordion.onclick = function() {return false;};
}
if (this.options.direction == 'horizontal') {
var options = $H({width: '0px'});
} else {
var options = $H({height: '0px'});
}
options.merge({display: 'none'});
this.currentAccordion = $(accordion.next(0)).setStyle(options);
}.bind(this));
},
//
// Activate an accordion
//
activate : function(accordion) {
if (this.animating) {
return false;
}
this.effects = [];
this.currentAccordion = $(accordion.next(0));
this.currentAccordion.setStyle({
display: 'block'
});
this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);
if (this.options.direction == 'horizontal') {
this.scaling = $H({
scaleX: true,
scaleY: false
});
} else {
this.scaling = $H({
scaleX: false,
scaleY: true
});
}
if (this.currentAccordion == this.showAccordion) {
this.deactivate();
} else {
this._handleAccordion();
}
},
//
// Deactivate an active accordion
//
deactivate : function() {
var options = $H({
duration: this.duration,
scaleContent: false,
transition: Effect.Transitions.sinoidal,
queue: {
position: 'end',
scope: 'accordionAnimation'
},
scaleMode: {
originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
},
afterFinish: function() {
this.showAccordion.setStyle({
height: 'auto',
display: 'none'
});
this.showAccordion = null;
this.animating = false;
}.bind(this)
});
options.merge(this.scaling);
this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
new Effect.Scale(this.showAccordion, 0, options);
},
//
// Handle the open/close actions of the accordion
//
_handleAccordion : function() {
var options = $H({
sync: true,
scaleFrom: 0,
scaleContent: false,
transition: Effect.Transitions.sinoidal,
scaleMode: {
originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight,
originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth
}
});
options.merge(this.scaling);
this.effects.push(
new Effect.Scale(this.currentAccordion, 100, options)
);
if (this.showAccordion) {
this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);
options = $H({
sync: true,
scaleContent: false,
transition: Effect.Transitions.sinoidal
});
options.merge(this.scaling);
this.effects.push(
new Effect.Scale(this.showAccordion, 0, options)
);
}
new Effect.Parallel(this.effects, {
duration: this.duration,
queue: {
position: 'end',
scope: 'accordionAnimation'
},
beforeStart: function() {
this.animating = true;
}.bind(this),
afterFinish: function() {
if (this.showAccordion) {
this.showAccordion.setStyle({
display: 'none'
});
}
$(this.currentAccordion).setStyle({
height: 'auto'
});
this.showAccordion = this.currentAccordion;
this.animating = false;
}.bind(this)
});
}
}
...waar doe ik dat?
Al mijn pogingen eindigen in alleen maar meer foutboodschappen...en die gaan voornamelijk over de 'syntaxis'...omdat ik niet exact weet waar ik de zg. 'catch' toe moet voegen.
Jij suggesties?
Gewijzigd op 01/01/1970 01:00:00 door Erick Schluter
Geen suggesties?
Added 27-12-2009:
Vreemd hoe sommige vragen op Fora gesteld worden en daarna in de vergetelheid raken...of nooit beantwoord worden.
Added 27-12-2009:
Vreemd hoe sommige vragen op Fora gesteld worden en daarna in de vergetelheid raken...of nooit beantwoord worden.
Gewijzigd op 01/01/1970 01:00:00 door Erick Schluter



