Mootools and ExtJs 4.x seem to be incompatible, how to solve? - extjs

Mootools and ExtJs have a compatibility issue when used on the same page. Mootools throws the following error :
Uncaught TypeError: Property 'id' of object #<HTMLDocument> is not a function
How can we use both frameworks side by side ? Is there a workaround ?

This looks like a document.id('..') reference issue, it is defined but it's not the mootools method...
Nothing will work if it's not pointed to the mootools method.
I would argue that ExtJS or your app has added a property id to document, which is not a function as is likely a String or another primitive.
Pretty sure that ExtJS would not have been overwriting document.id, especially given that they (Sencha) employed MooTools core team dev #subtlegradient (thomas aylott) who co-wrote the Slick selector engine and helped engineer the document.id transition in MooTools from the simple $ in 1.11
You probably cannot do document.id = $ to restore it as it's by reference and it's been overwritten.
Only chance is to try loading MooTools after ExtJS is loaded and started - or load MooTools, save a ref like document.$id = document.id; immediately after, load ExtJS and then restore it back when ready via document.id = document.$id; delete document.$id - still no guarantees this will run at the right time. you really need to see what modifies your document object in web inspector (you can add a watcher)

Related

Liferay 7.1 npm-react-module localization

I'm trying to include localization into my npm-react-module, but I have failed receiving the value for the corresponding key from the Langugage.properties file. It simply returns the key. I did some research but I couldn't find any source that would help me solve my problem.
In the code which I will show you bellow, I have included a Language.properties file into my module. In my portlet, I have included the needed configuration for the language properties. I have also tried to add a separate file for a specific locale, but that didn't help me either.
This is an example of my portlet configuration:
"javax.portlet.resource-bundle=content.Language"
This is an example content from my Language.properties file:
example-key=example-value
This is how I'm trying to access the value in my React Component:
<h1> {Liferay.Language.get('example-key')} </h1>
But it only returns "example-key" instead of "example-value".
In my view.jsp file I am able to retrieve the corresponding values using
<liferay-ui:message key='example-key'/>
I have tried this method: https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/localizing-your-portlet but it didn't work either. Did anyone get this to work properly in their npm-react-module? I really don't want to spend time implementing my own localization service. Thanks!
Liferay.Language.get('key') gets text replaced by the build mechanism. Therefore there is no actual object/class to do this. I have been trying to get this to work myself and have resolved that I will have to do internationalization on my own.
localizing is done only in build time meaning if you have a language
key that generated dynamicly , you can't localizate it or for example
if you get a key from api fetch and need to localizate it, you can't
beacuse Liferay localization method for react (
Liferay.Language.get("yourLanguageKey") ) its undefined in runtime and
you can't use it.
from: https://npm.io/package/liferay-react-runtime-localization

Close method not working in Office

Im trying to use Microsoft.Office.Interop.Word._Document.Close() in a .net 3.5 windows form app.
No matter how much I search here and on Google I cannot find the correct parameters to put in the Close method.
I am using version 14.0.0.0 of Microsoft.Office.Interop.Word and I would like to close the document without saving and ideally ensure that the application can isolate the document thread so that users can still open word documents outside the running application.
See the Close method of the Document class described in MSDN. If you need to omit the parameter and use the default value - pass the Type.Missing parameter.
Try this:
object doNotSaveChanges = Word.WdSaveOptions.wdDoNotSaveChanges;
object missing = System.Reflection.Missing.Value;
_Document.Close(ref doNotSaveChanges, ref missing, ref missing);
This is the source
I'm not sure if you'll need the middle line or not. It's not from the original source it's from here

Print a custom object on console in extjs

I am trying my hands on extjs 4.2.2 on a UI development. I am totally new to this. I am unable to understand how to print the objects for which i dont know the properties. Can someone please help me out in this.
If i know the property of the object i can do it as below.
console.log('print: ' + myObj.get('name'));
But if i dont know the property(in this case name) how can get to print it? Is there any way of iterating the object properties and print it. Kindly help me on this.
Yes, you can iterate through properties of an object using for .. in loop
for (var prop in obj) {
console.log("o." + prop + " = " + obj[prop]);
}
Another way would be to encode the object to string:
console.log(Ext.encode(o))
However, I usually log the complete object console.log(o) and the I use the console UI to browse through properties of interest.
In addition, you might want to consider installing the 'App Inspector for Sencha plugin' from the Google Chrome app store, its a free plug in from Sencha. Very handy, easy to use visual tool to peek under the hood and view components and their methods, properties and values, view what stores exist and the data in them, view the layout, view the events and record which events are getting triggered.
Also, worth considering is using Ext.ComponentQuery which I find very useful. I tend to use this directly in the web browser console window and in my EXTJS console.log statements.
These links will help explain ComponentQuery
http://training.figleaf.com/tutorials/senchacomplete/chapter2/lesson5/2.cfm
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.ComponentQuery
http://devjs.eu/en/how-to-use-ext-component-query-in-ext-js-4/

Store not being read or recognized

I get this error when I try to start up my ExtJS 4.2 app:
Uncaught TypeError: Cannot read property 'buffered' of undefined
I've double checked all my store ids and and names to ensure that they are all spelt correctly but I'm still having this issue :(. Is there anything else I could try to solve this error?
Thanks in advance.
I typically get this error when one of my grids is referencing a store that has not been defined in either the controller instantiating the view or app.js (depending on how the app is structured)
In my case, usign Sencha Architect 3.5, I had to drag to the Store Section the store and it works again. I didn't know when the Application loss the relation with the store but doing that it's working again.

CakePHP Media Plugin Helper problem

I am trying to display an uploaded image with the Media Plugin of CakePHP.
I added the helper to the controller helper array: var $helpers = array('Media.Media');. Then, in my view, I have this code: echo $media−>file($news['Attachment'][0]['dirname'].DS.$news['Attachment'][0]['basename']);. But the problem is that, it outputs this error:
Undefined variable: media− [APP/views/news/view.ctp, line 3]
What could be the problem?
By the way, if a plugin has a model User in app/plugin/users/models/user.php and i create a new model called User in the app/models folder which one will be loaded?
Thanks in advance for any help!
First off if you are using 1.3.x refer to helpers via $this->HelperName->method(), there could be a variable called $media being set in some method. you can check this by doing var_dump($media);
The other option is that something has maybe unset it. Its very strange that you have the helper set but the variable is not set. It could also be due to adding the $helpers array to the wrong controller, you can try add it to app_controller and see if that works. if it does you had it in the wrong place.
If i got your second question correct, and we are talking about auto loading, a plugin controller will first look for the model in its own plugin directory, if it is not found there it will fall back to the app/models directory.
if you are loading it manually via the $uses array, it depends on the version of cake and how you do it. In previous versions 1.x even $uses = array('User'); would load the plugin model as cake would auto add the plugin prefix. This has changed for 2.0 afaik.
For other methods of loading a model, such as $this->loadModel('User); would load from app/models and $this->loadModel('PluginName.User') would load from the app/plugins/plugin_name/models dir.
Edit:
you are right that is funny having the error show $media- and there is the problem. did you copy that code from some site? − is not - you have a utf8 char in the code which is what its complaining about.

Resources