Explain ExtJS 4 event handling

Let’s start by describing DOM elements’ event handling. DOM node event handling First of all you wouldn’t want to work with DOM node directly. Instead you probably would want to utilize Ext.Element interface. For the purpose of assigning event handlers, Element.addListener and Element.on (these are equivalent) were created. So, for example, if we have html: … Read more

Any suggestions for testing extjs code in a browser, preferably with selenium?

The biggest hurdle in testing ExtJS with Selenium is that ExtJS doesn’t render standard HTML elements and the Selenium IDE will naively (and rightfully) generate commands targeted at elements that just act as decor — superfluous elements that help ExtJS with the whole desktop-look-and-feel. Here are a few tips and tricks that I’ve gathered while … Read more

Best practice for overriding classes / properties in ExtJS?

For clarification: By real class modification I mean a intended permanent modification/extension of a class, which should always be done by extending a class. But it is not a temporary solution for just a specific problem (bug-fix, etc.). You have at least four options how to override members of (Ext) Classes prototype I guess is … Read more

How to retrieve Request Payload

If I understand the situation correctly, you are just passing json data through the http body, instead of application/x-www-form-urlencoded data. You can fetch this data with this snippet: $request_body = file_get_contents(‘php://input’); If you are passing json, then you can do: $data = json_decode($request_body); $data then contains the json data is php array. php://input is a … Read more

How to display binary data as image – extjs 4

Need to convert it in base64. JS have btoa() function for it. For example: var img = document.createElement(‘img’); img.src=”data:image/jpeg;base64,” + btoa(‘your-binary-data’); document.body.appendChild(img); But i think what your binary data in pastebin is invalid – the jpeg data must be ended on ‘ffd9’. Update: Need to write simple hex to base64 converter: function hexToBase64(str) { return … Read more

How can I let a user download multiple files when a button is clicked?

The best way to do this is to have your files zipped and link to that: The other solution can be found here: How to make a link open multiple pages when clicked Which states the following: HTML: <a href=”#” class=”yourlink”>Download</a> JS: $(‘a.yourlink’).click(function(e) { e.preventDefault(); window.open(‘mysite.com/file1’); window.open(‘mysite.com/file2’); window.open(‘mysite.com/file3’); }); Having said this, I would still … Read more

Javascript: Uploading a file… without a file

If you don’t need support for older browsers, you can use the FormData Object, which is part of the File API: const formData = new FormData(); const blob = new Blob([‘Lorem ipsum’], { type: ‘plain/text’ }); formData.append(‘file’, blob, ‘readme.txt’); const request = new XMLHttpRequest(); request.open(‘POST’, ‘http://example.org/upload’); request.send(formData); File API is supported by all current browsers … Read more

How to stop a setTimeout loop?

setTimeout returns a timer handle, which you can use to stop the timeout with clearTimeout. So for instance: function setBgPosition() { var c = 0, timer = 0; var numbers = [0, -120, -240, -360, -480, -600, -720]; function run() { Ext.get(‘common-spinner’).setStyle(‘background-position’, numbers[c++] + ‘px 0px’); if (c >= numbers.length) { c = 0; } … Read more

Javascript how to parse JSON array

Javascript has a built in JSON parse for strings, which I think is what you have: var myObject = JSON.parse(“my json string”); to use this with your example would be: var jsonData = JSON.parse(myMessage); for (var i = 0; i < jsonData.counters.length; i++) { var counter = jsonData.counters[i]; console.log(counter.counter_name); } Here is a working example … Read more

tech