Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:37:48+00:00 2026-06-06T11:37:48+00:00

I’m using a code that looks like that: img.load(function(){ // do some stuff $(this).width();

  • 0

I’m using a code that looks like that:

img.load(function(){
    // do some stuff
    $(this).width();

});

In my callback the image size is always 0. It might have something to do with it but my images are locally loaded.

But in truth, if I do this.width, I will get the expected width and then I can do some kind of computation from here to change my extjs window.

After some tries, I realize that if I do $(this) all the attributes I changes don’t seem to have any effect at all.

doing $(this).width(40); won’t change the width of my image but doing this.width = 40 will change the width of my image. It’s as if doing $(this) was copying my HTMLImageElement within a new element and those change would be applied only if I added to the dom again to replace the old one.

I’m not so sure to understand what’s going on there.

Edit

This is what my img variable contains.

img = $('<img>');
img.attr('src', '....image');

Edit 2

This doesn’t really change the fact that jQuery doesn’t handle image size for in memory images but I felt it would be good for anyone using Extjs to not repeat my error. One of the big problem in my case is that the img object I used was a valid object but since I’m using ExtJs, I inadvertently made a stupid mistake. I created my window that way…

Ext.create('Ext.Window', 
  // some settings
  items: [{
      html: img.wrap('<div>').parent().html(),
  // etc

In other word, the event I created was on img, but I never really added img to the DOM. ExtJs added html text to the DOM which created a new object which can’t be modified through event and so on.

So I do have to create an id to find the new element and all of this has to be done after a call to modalWindow.show() is done. After that everything works perfectly.

For resizing the window, if the dimensions are set, you can set them back to null and do a doLayout call on the window and it will recalculate windowsize.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:37:50+00:00Added an answer on June 6, 2026 at 11:37 am

    You found out that jQuery(this).width() does not work for images in memory. Choices are to use this.width/height or append it to the page and read it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.