PDA

View Full Version : Newbie problem with button onClick



TheBerliner
10 Aug 2009, 2:57 AM
Hello,

I am new to EXT JS and also to JavaScript and I'm having problems with the very simple task of equipping a button with an onClick action.

I have looked at all the examples and tried all variants over the past six hours, but still EXT refuses to generate any onClick action. In most of the examples, the onClick function is directly added to the handler: in the button declaration. Since I'm having the same function being called by many buttons, this wouldn't be a viable solution.

My goal is to have an existing function clickAction(widgetName,value) being called when the button is pressed. Very simple but still unclear (from the very sparse documentation).

Here is my button declaration (I apologize for the not indented code but this editor refused any indentation or adding blanks and offers no tabs and I found no other way of presenting it nicer):



var buttonPorECToolsHand = new Ext.Button({ id: 'buttonPorECToolsHand',
iconAlign: 'top',

clickEvent: 'ecBrowToolHand', // unclear what this is for (bad & minimal documentation)
// I also tried 'click' here with the same result
scale: 'medium',
icon: 'picECToolsHand.gif',
pressed: 'true',
xtype: 'button',
handler: clickAction, //here I tried all variants that are used in the examples - no chance!
iconCls: 'buttonPorECToolsHand',
cls: 'buttonPorECToolsHand'
});

The function, which is supposed to be called, looks like this (reduced code, irrelevant parts left out):



function clickAction(widgetName,value){

storeActualTabInfo();
if(clickActionsNum>=omitedClickActions){

if(widgetName == "ecBrowToolPrevious") prevPage(); else
if(widgetName == "ecBrowToolHand") clickHand();else
//Irrelevant parts left out
}
}


This function is not the problem. Execution never gets there. And it works in an older prototype, which was developed without EXT.

This is the related extract from the CSS file:



.buttonPorECToolsHand{
buttonPorECToolsHand: url("picECToolsHand.gif") !important;
}

Here is the HTML, which is generated from this code (with a lot of empty and unneeded <td>s):



id="ext-gen75" class="x-table-layout-cell">
<table id="buttonPorECToolsHand" class="x-btn buttonPorECToolsHand x-btn-icon x-btn-pressed " cellspacing="0">
<tbody class="x-btn-medium x-btn-icon-medium-top">
<tr>
<td class="x-btn-tl">
<i> </i>
</td>
<td class="x-btn-tc"/>
<td class="x-btn-tr">
<i> </i>
</td>
</tr>
<tr>
<td class="x-btn-ml">
<i> </i>
</td>
<td class="x-btn-mc">
<em class="" unselectable="on">
<button id="ext-gen77" class="x-btn-text buttonPorECToolsHand" type="button" style="background-image: url(picECToolsHand.gif);"> </button>
</em>
</td>
<td class="x-btn-mr">
<i> </i>
</td>
</tr>
<tr>
<td class="x-btn-bl">
</td>
<td class="x-btn-bc"/> //empty, too
<td class="x-btn-br"> //empty, too
</td>
</tr>
</tbody>
The button with it's icon show up.

I would very much appreciate if somebody could just give me the correct syntax for the declaration of the onClick receiver (handler) so that the clickAction is called when the button is clicked with the parameters transferred as described in the manual:
a) the Button (or its id) and
b) the EventObject.

I'm sorry to bug the community with such simple problems but this is a consequence from the very sparse and incomplete documentation (I have read all available tutorials etc and spend a lot of time on this but many details are missing or listed only in a minimal form usable only for experts - and manuals should be written for beginners).

Thank you very much for your help

evant
10 Aug 2009, 3:11 AM
If you didn't know what it was for, why would you change the clickEvent?

That config option could do with a bit of expanding, the purpose of it is to indicate which dom event will fire the button handler (for example, click, dblclick, contextmenu).

Condor
10 Aug 2009, 3:12 AM
1. You should definately NOT change the clickEvent config option (and if you need to you should proably only use 'click', 'dblclick', 'mousedown' or 'contextmenu').
2. Those <td> elements in the markup are required to get the button to show correctly with every size.
3. The API docs (http://extjs.com/deploy/dev/docs/?class=Ext.Button&member=handler) say that the parameters for the handler function are the button and event object (so not the id).

TheBerliner
10 Aug 2009, 3:17 AM
If you didn't know what it was for, why would you change the clickEvent?
Not change, rather set at all.

Due to the many deficiencies of the documentation, "trial and error" is the only way to find out how things work.

For example: The sparse mnimal text about clickEvent says only: "The type of event to map to the button's event handler (defaults to 'click')" but it does not say what the other accepted settings are. How should one know? (if not an expert who does not need doc anyway)

You (in the developmen team) seem to have no idea, how difficult and time-consuming it is (even for an oo veteran with >25 yrs like me) to start using EXT with this so-called documentation where one has to assume that such a newbie is also new to JS as such. Trial and error is the only way.

For example: I first tried to have PNG files as icons for these buttons. There are examples where PNG are used for icons. It never worked. I wasted more than 10 hours with all variants. Then I changed only the extension to gif and created the gif files and it worked immediately. In other words, the doc is wrong, because it says nothing about this.

BTW: How are mouseOver set? I did not find this either. Only the events are listed but not how to set them to some function.

evant
10 Aug 2009, 3:20 AM
It says "defaults to click". Surely you could infer what it was for.

Anyway, I've updated the documentation in SVN to make it more clear.

danh2000
10 Aug 2009, 3:27 AM
even for an oo veteran with >25 yrs like me

OMG! here we go AGAIN!

If I were you I wouldn't bring attention to that because it makes you look even MORE stupid!

TheBerliner
10 Aug 2009, 3:28 AM
1. You should definately NOT change the clickEvent config option (and if you need to you should proably only use 'click', 'dblclick', 'mousedown' or 'contextmenu').
Well, thank you for listing the other alternatives, which are missing in the doc.



3. The API docs (http://extjs.com/deploy/dev/docs/?class=Ext.Button&member=handler) say that the parameters for the handler function are the button and event object (so not the id).

a) Those are what I must get back when the button is pressed. Makes no sense in my view to set these to the button (in the case of the button that would be "self" really, so why set the button to the button?

b) And what - just as an example - would be legal parameters?

So what is wrong in my button declaration?

Animal
10 Aug 2009, 3:30 AM
Not change, rather set at all.

Due to the many deficiencies of the documentation, "trial and error" is the only way to find out how things work.

Oh for god's SAKE!

TheBerliner
10 Aug 2009, 3:30 AM
OMG! here we go AGAIN!

If I were you I wouldn't bring attention to that because it makes you look even MORE stupid!

Don't you think it's a waste of - your and my - time to get into personal allegations? I do think so - and won't respond to it. Seems you don't like the truth!

TheBerliner
10 Aug 2009, 3:36 AM
Oh for god's SAKE!
The truth remains the truth - if you like it or not. As awesome as the product is, as awful is the documentation.

I could list dozens of problems and errors that derived from missing, misleading and/or sparse documentation. This has cost me hundreds of hours over the last weeks.

Animal
10 Aug 2009, 3:40 AM
Are yiou BLIND?

Animal
10 Aug 2009, 3:40 AM
Hundreds of hours?

You must be UNIQUELY incapable of writing software.

TheBerliner
10 Aug 2009, 3:42 AM
Hundreds of hours?

You must be UNIQUELY incapable of writing software.

Seems you have had a very bad weekend, or your girl-friend refuses you her "duties"? So that you step to such a low level of discussion.

steffenk
10 Aug 2009, 3:52 AM
please calm down.

I don't really get the problem, using the handler in Ext.Button was one of my very first scripts, and i did it following the examples and the API, so i don't get where the misunderstanding comes from. API tells you exact which events are possible, you even can browse the source code from there if you are unsure.

I have to say that it tooks me a while to learn how to read the API, but after it's one of the best helping docs i know.

TheBerliner
10 Aug 2009, 3:57 AM
please calm down.

I don't really get the problem, using the handler in Ext.Button was one of my very first scripts, and i did it following the examples and the API, so i don't get where the misunderstanding comes from. API tells you exact which events are possible, you even can browse the source code from there if you are unsure.

I have to say that it tooks me a while to learn how to read the API, but after it's one of the best helping docs i know.

Thank you for your reply but unfortunately it does not bring me any millimeter ahead. All I would need is the one line in the button declaration that invokes the clickAction funtion and passes some identification of the button and the event fired.

It's so simple and could have been explained in three minutes by the doc authors with a few lines. Unfortunately, the examples don't help either, because almost all of them have the whole funtion directly attacted to "handler:", which is unrealistic in most cases in real life.

Again: I tried all logical variants and never was any onClick generated.

steffenk
10 Aug 2009, 3:59 AM
what's wrong with simple solution?


new Ext.Button({
renderTo: 'dp-gv',
text: 'Get Value',
handler: function() {
alert(dp.getValue());
}
});

Animal
10 Aug 2009, 4:01 AM
I wouldn't waste your time here Steffen.

This is what the "add user to ignore list" option is for.

TheBerliner
10 Aug 2009, 4:08 AM
what's wrong with simple solution?


new Ext.Button({
renderTo: 'dp-gv',
text: 'Get Value',
handler: function() {
alert(dp.getValue());
}
});

Pardon, I wrote that there is ONE function used by MANY buttons (and other widgets). You don't seriously expect me to repeat a (40 lines) function over and over again?!

I thought EXT is what is called "object-oriented" in JS. Your proposal certainly is not.

But it seems to be difficult for the experts to answer my very simple question. I am suprised.

BTW and for your understanding:
The button declaration is written out automatically from Smalltalk code and there are only 3 lines of code in a tiny little Smalltalk method to generate this code, which in the end will be done dynamically as part of the application run by the end-user (NOT a programmer, no coding). It's all part of a website generator.

TheBerliner
10 Aug 2009, 4:09 AM
I wouldn't waste your time here Steffen.

This is what the "add user to ignore list" option is for.

Good idea, I would appreciate if YOU (Animal) were using it for MY posts!

Thank you!

TheBerliner
10 Aug 2009, 4:40 AM
I tried this:



var buttonPorECToolsHand = new Ext.Button({
id: 'buttonPorECToolsHand',
iconAlign: 'top',
clickEvent: 'click',
scale: 'medium',
icon: 'picECToolsHand.gif',
pressed: 'true',
xtype: 'button',
handler: function(){clickAction('buttonPorECToolsHand')},
iconCls: 'buttonPorECToolsHand',
cls: 'buttonPorECToolsHand'
});


...but same result: NO onClick is generated!

Syntactically ok (JSLint says ok) and button is shown but not action and no onClick in HTML.

Condor
10 Aug 2009, 5:02 AM
Are you sure this isn't a scope problem?

Is clickAction actually accessible when you are using it in the button config?

TheBerliner
10 Aug 2009, 5:11 AM
Are you sure this isn't a scope problem?

I think know what you mean with scope but I have no clue how this could be the case. The button exists in JS and HTML, it shows up correctly but it has no onClick property (or any other). Therefore, there can never arise any situation that the receiving function (onClick) is not reached, because there is no onClick action at all.


Is clickAction actually accessible when you are using it in the button config?
Yes, it would be accessible if there was any execution of any onClick action. The problem is that even this (in my view ugly code but never mind) solution is not rendered to HTML. There is no code for the handler function in the HTML although form and buttons show up well.

Actually, what I intend to have EXT generate is so extremely simple: just some code like:

onClick="javascript:clickAction(buttonPorECToolsHand)"
so that the ID of the clicked widget is sent to the receiver, which really includes an AJAX function communicating with the server. This receiving function (clickAction) is used for many types of widgets.

What I was first looking for was some setter to add the parameter for the onClick event (here: clickAction) to the button parameters. And I don't understand why such a trivial setter does not exist in EXT.

I am completely shocked that such a primitive subject is such a problem....!

Condor
10 Aug 2009, 5:21 AM
Try this:

var buttonPorECToolsHand = new Ext.Button({
id: 'buttonPorECToolsHand',
iconAlign: 'top',
//clickEvent: 'click', <- not needed, this is the default
scale: 'medium',
//icon: 'picECToolsHand.gif', <- don't use both icon and iconCls - iconCls is preferred
//pressed: 'true', <- only with enableToggle:true
//xtype: 'button', <- not needed, you already use the Ext.Button constructor
handler: function(){
console.log(clickAction); // what does this show?
clickAction('buttonPorECToolsHand');
},
iconCls: 'buttonPorECToolsHand' //,
//cls: 'buttonPorECToolsHand' <- use for advanced styling, not for a simple icon
});

The 'console' statement only works in Firefox with Firebug installed (A good javascript developer can't do without them!).

TheBerliner
10 Aug 2009, 5:32 AM
dank je wel, heel vriendeliik

(got my problems with the spelling but my biggest customer is this "little" electric company in the south of your country).

I will try.

(A good javascript developer can't do without them!).
An a newbie in JS like me even less. This is why Firebug was the very first thing to start with (but it's a stone-age nightmare compared to the enironment we normally work in).

I will report the result.

TheBerliner
10 Aug 2009, 7:30 AM
Résumée:
It was all caused by bugs in EXT JS and worsened by:
- the absence of proper documentation
- the failure to document requirements of the EXT JS library.

Bad news first:
1) No result of your change after making your changes to the code:
a) No onClick rendered into HTML
b) This action to console not executed
c) Icon image is not shown any more
d) The generated HTML was identical to my previous version.

2) Icon was not shown any more (only empty button).
This was healed after I added the icon: 'picECToolsHand.gif' again. This seems mandatory as well as the iconCls: 'buttonPorECToolsHand'.

Now the good news: it worked

3) After I reinstalled the icon: 'picECToolsHand.gif' it worked! Click action reconginzed.
Concrete:
Console shows: clickAction(widgetName, value)
and henceforth the debugger stopped in the clickAction.

Thank you very much indeed!

4) Cause of the error
I wanted to find out what causes this bug in EXT (obviously this is a bug and any such undocumented and unexpected behaviour MUST BE valued as a bug, too). So I continued my usual and partially stochastic "trial and error" testing for another about 60 minutes but I was unable to find the reason in the old code that caused this bug. I then gave up.
Nevertheless, there is still no onClick rendered and the HTML looks the same as before.

So I would actually be curious to know how this is done, but I don't want to stress your time and support any further.

BTW: I reverted back to the old version just to make sure that I had not fooled myself and no, it still does not work with the old version. So my statements were correct.

5) Another little subject:
In all EXT examples the argument true is NOT enclosed in any quotes. In your example, you did enclose 'true' in single quotes. Now, I know that double and single quotes are equivilant in JS (which is confusing enough) but how about true? Seems it does not matter if that is included or not?! Very confusing and inconsistent concepts in JS!

6) Sequence of loading libraries - more bugs
One other finding durent recent testing: Your "scope" proposal made me change the sequence of the loaded libraries. Currently in development state, there are about 12 JS and CSS files all together. They will be merged to far less when the JS generator is finished, of course.

7) Another bug in EXT Button / icon
When I remove the icon: setter to the code below, the icon image itself is not shown any more. There is no plausible reason for this and it's not mentioned in the manual either.

There must be more bugs in EXT JS (euphemizing labeled as "issues" in US English), because after I placed the library that contains the "clickAction" and some more functions earlier in the sequence (but still after ext itself) the entire browser remained empty and nothing of the form showed up. So I reverted this to the old sequence.

Again: Hartlik dank!

It's very frustrating to have to rely on stochastic trial and error and on volounteer's support just because the EXT management does not value documentation as to what it deserved.

8) Message to the developers
Offering nothing (obviously, not really documented) but a full function as paramter for "handler:" is a very bad and stupid solution for setting onClick and other very frequently used properties. Very very bad!

This is the code that I used and which finally works:


var buttonPorECToolsHand = new Ext.Button({

id: 'buttonPorECToolsHand',
iconAlign: 'top',
scale: 'medium',
icon: 'picECToolsHand.gif', //if missing, there is no icon image
iconCls: 'buttonPorECToolsHand', // this is needed, too with file name in CSS
pressed: 'true', //this should start in mode pressed
enableToggle: true, //this is supposed to toggle
handler: function(){
console.log(clickAction); // what does this show?
clickAction('buttonPorECToolsHand');
}
});

A message to Mr. Slokum: Your failure to deliver a proper documentation has again cost me many wasted working hours! And this is what your supporters additionally call the customer stupid for. Thank you very much!

TheBerliner
10 Aug 2009, 7:38 AM
Hundreds of hours?

You must be UNIQUELY incapable of writing software.

Animal,

If you had received a little bit of decent education and proper upbringing of the form that was practised in my former grammar school that I attended in Wimbledon, you would rather beg for pardon for your previous impertinences!

But I doubt that so supposingly you better leave your ignore filter on for my future posts!

Regards

danh2000
10 Aug 2009, 1:45 PM
Can't somebody ban this *****? The community don't want his sort around here. He's constantly rude and insultive and doesn't have the intelligence to use JavaScript or Ext.

steffenk
10 Aug 2009, 1:50 PM
you seem to be new to Javascript in general, as i read a lot of misunderstandings.

What happen in HTML if the src of a pic is wrong? Right, it's not shown. Same happens in ExtJS.

You don't know DOM events. There is no written tag for it, events are attached to DOM elements, you should read about this.

true or false never get quoted, they are boolean, not strings (same in other languages)

you should read something about scope. Not all of the objects are visible in handlers, they have to be binded with scope.

nearly all objects have property listeners where all events can be configured. handler is just a shortcut to listener click.

console prints every time the script is running. If nothing is printed, the line isn't executed. Debug to find out why.

sequence of loading files doesn't matter if you use a good application design. If it's matter, you do something wrong. Only last file complete the app. Read the tutorial about application design.

Sorry, but what you posted as bugs are no bugs, you only missed to use them right. Don't think if you miss it's bcause the framework, the language or the doc, nearly all users are completely pleasured with the doc. If you really find a bug, make a online sample to demonstrate it and make sure your code is right.

TheBerliner
10 Aug 2009, 1:52 PM
Can't somebody ban this *****? The community don't want his sort around here. He's constantly rude and insultive and doesn't have the intelligence to use JavaScript or Ext.

Absurd! And rediculous.

After several bugs have been detected and proven, this is just absurd! Especially, since - if you read the thread - the insults were started by Animal without any reason.

But that's what a herd of sheeples reacts like!

TheBerliner
10 Aug 2009, 1:55 PM
you seem to be new to Javascript in general, as i read a lot of misunderstandings.
That was my first phrase!

Sorry, but what you posted as bugs are no bugs, you only missed to use them right.
Clearly bugs - and, as I wrote, undocumented and unexpectable behaviour, which as a resuilt must also be valued as a bug. Documentation MUST BE part of thr product.


But I have wasted far too much time on this rediculous onClick setting that I am not going to waste more on discussions.

It is beyond my comprehension how such a badly and partially false documentation can be accepted by obviously many people. BTW: And at least one of my critics was admitted by "event" (post #5). So what?!

danh2000
10 Aug 2009, 2:03 PM
it's obviously all beyond your comprehension isn't it. Give up and hire someone who can comprehend!

TheBerliner
10 Aug 2009, 2:06 PM
it's obviously all beyond your comprehension isn't it. Give up and hire someone who can comprehend!
Insults by sheeples!

Typical human forum reaction of the herd when one of the "leader sheep" was critizised. Proves me right.

Good night - got better things to do now!

danh2000
10 Aug 2009, 2:13 PM
I know you have better things to do - like learning so that you don't have to spend hundreds of hours (ouch) on a simple piece of code that you STILL don't understand.

Like I said, you don't have the intelligence required to use JavaScript or Ext - this isn't an insult, it's a fact that you have demonstrated.

Condor
10 Aug 2009, 11:22 PM
...
Bad news first:
1) No result of your change after making your changes to the code:
a) No onClick rendered into HTML
b) This action to console not executed
c) Icon image is not shown any more
d) The generated HTML was identical to my previous version.


1. Were you actually expecting to seen an onclick="..." in the HTML? All javascript libraries I know use addEventListener/attachEvent to be able to register/unregister multiple events, so you will never see an onxxx handler in HTML.

2. The iconCls wasn't working because your CSS rule is not valid:

.buttonPorECToolsHand{
background-image: url("picECToolsHand.gif") !important;
}

3. Please don't blame Ext LLC for Animal's statements. As you can read in Animals signature: He is a volunteer that has no affiliation with Ext LLC.

Animal
11 Aug 2009, 12:14 AM
Saint Condor struggles on!

TheBerliner
11 Aug 2009, 2:17 AM
Saint Condor struggles on!
...you better stick to your promise to ignore my posts!

TheBerliner
11 Aug 2009, 2:27 AM
@Condor

Thank you for your hints and critics!

1) Yes, originally I had expected that some HTML onClick would be generated and this was due to my limited knowledge of JavaScript and the entire environment. When it worked, I realised that there must be some other mechanism.

2) Oh! Yes, you are right.
Thank you very much for this hint! In fact, only the very first version was handwritten and the later ones generated together with the code for the buttons. Due to change this bug slipped in. Not good if one doesn't use SUnit Xtreme test cases for really all (and I currently only do for the basics of the generator).

As I wrote before, I am at the same time developing a JavaScript and CSS code generator, which in the end will write out all JavaScript definitions for EXT of the entire user interface from data (essentially key/value pairs), through which the UI is defined both for the desktop application and now also for HTML. The desktop part has been in use for years and it covers also the entire and very complex model. Like this, system, version and user settings are reflected directly in the generated JS for the UI.

3) Never mind! My problem was with this person's attitude not with the company (except for the documentation, which I still find by far too sparse).

4) Perhaps as an explanation about the background

I had expected that one has to pass some reference to the handler property and not an entire function, which always means duplicating a lot of unnecessary code. And the best code is the one that is never written, because it's the only one that is guaranteed to be bug free.

Honestly, I find this a very cumbersome and "unclever" solution, especially since most of the arguments will certainly refer to some standardised functions, which are applied to several our many such cases. Also, this form of implementation seduces the coders to create redundancies, which is never any good.

If there had been any hint in the documentation that a full function is required, most of the fuss would have been avoided. Especially, it still is unclear (and makes no sense to me) that it says:

"A function called when the button is clicked (can be used instead of click event)." Ok, first question: What expects click event really, only the default is listed, no other choices, no real explanation.
parameters:
* b : Button
This Button.
This means that one should send "self" (This button) as value?! Can't be true. That would be recursive. And at declaration time the button does not yet exist. So how should one pass this "function called when the button is clicked..." at generation time? Completely wrong wording.

And more:
EventObject
The click event.
How can one send an EventObject (instance, really) in a declaration, which does not even exist at this time. Therefore, this can only be some identifier (symbol or so) of an event.

This alone is an extremely misleading and in my understanding wrong description. And most of the examples contradict these statements as they contain no such arguments. In fact, most handler funcs in the examples have no args at all. How should one align this with the misleading documentation text?!

Perhaps the reason is just in the fact that all of this has obviously been written by programmers who are never good in documentation and most of them not in wording either as they are mathematical people. Also, most programmers are just too ignorant to acknowledge that somebody does not understand their clever, brilliant and clear code. Had that many times!

I make an attempt for a better explanation:

The only allowed value of the handler argument is some full function code, which must be declared in here. (Or are also variables allowed, which point to a function that was declared before?) This function will be called when the event XYZ (which one? Still don't know, more than onClick?) fires. It will receive two parameters (see above, This button and EventObject) although this function will also be accepted with no parameters. (how about one?)

Please see this as my constructive attempt to show you what I would regard to be a better doc, although a doc pro would certainly find much better wording.

But, of course, a JavaScript expert would probably have understood what you were expecting and trying to say with the misleading doc. Another problem for a newbie to JS is in the fact that (and this does not refer to EXT JS) this primitive JS interpreter and browser does not report all errors but just does nothing or show a blank screen. This is of course not your fault but a lausy idiotic impelementation of the browser people that makes it very difficult to detect such errors (and Firebug won't help here either). This is why I always use JSLint but this does not help in all cases, of course. Another reason why doc must be better than "normal" where compilers or interpreters offer very much better debugging features.

Documentation must always assume the reader to be a beginner regarding the documented subject. Also, I am absolutely sure that the explanations for many of the other properties are gravely insufficient.

And again: Forcing a full function as arg is a very bad solution. A pointer or symbol for use by eval would be very much better. I had never expected such a trivial redundant arg to be possible.

It's not only my experience that any hour invested into the documentation pays back multiple times in less support and in much higher user satisfaction.

(Dictated with voice recognition, therefore probably not bug-free. I apologize)

Condor
11 Aug 2009, 2:52 AM
OK, I think you are misunderstanding event handling a bit.

Any callback function (like 'handler') or event handler (see 'listeners') has a parameter signature: the parameters that are passed when the function is called.

The button handler callback will be called with 2 parameters:
- the button that was clicked
- (a copy of) the event that triggered the click.

So you could specify:


hander: function(btn, evt){
// btn will be the button that was clicked
// evt will be the click event
}

But you could also use:

function buttonClick(btn, evt){
// btn will be the button that was clicked
// evt will be the click event
}
and use this function in multiple buttons:

hander: buttonClick
(you had this code before, but I assume it didn't work because buttonClick was defined in a different scope, so it wasn't accessible when you were creating the button)

new2ext
12 Aug 2009, 9:31 PM
Insults by sheeples!

Typical human forum reaction of the herd when one of the "leader sheep" was critizised. Proves me right.

Good night - got better things to do now!

It is your elitist attitude that turns people off. You have been recommended several times in your other threads to take a step back and learn about the idiosyncrasies of Javascript (and by extension ExtJS) before proceeding. But you seem complacent and determined to code ExtJS/JS with how you see SmallTalk behaving, which may run counter to Javascript standards. The majority of the hours that you spent struggling with this frame can be traced back to your unwillingness to accept that different frameworks behave differently.

You are very quick to place blame when something goes wrong. You don't spend enough time evaluating the options in front of you and when something goes wrong, your tendency is to assume that the documentation is poorly written. The documentation is anything but poor. You may disagree, but many before you, including myself, started without any prior experience with JS and have done just fine with the help of the documentation and the sample code in the examples. You should look into the examples provided in the SDK as an additional reference if you have questions on how something should be implemented. It would have answered some of the questions that you have asked in this thread.

With regards to your first post about indenting code, you can use either the [code] tags or [php] tags to reference your code snippet.

TheBerliner
14 Aug 2009, 5:06 PM
(you had this code before, but I assume it didn't work because buttonClick was defined in a different scope, so it wasn't accessible when you were creating the button)
Yes, I had tried this before. Ok, I will try again ASAP. It worked with the full funcs but that is redundant code and also ugly.

Thank you very much again for these explanations.

(I was travelling, therefore the delay)

TheBerliner
14 Aug 2009, 5:09 PM
@new2ext

Live is too short to waste it on bad wine, frigid women, or fuitless discussions about personal allegations!

My best regards


Still a P.S.:
a) Your assumptons are wrong (Smalltalk / JS etc)
b) The doc IS LAUSY and near to unuseable for a newbie.
c) Learning by doing with doc reading in between has been my most successful way of learning for >25 yrs.