PDA

View Full Version : What object to use for display an image by itself?



mikerthomsen
3 Mar 2010, 7:01 AM
I'm new to ExtJs and am trying to learn it by reimplementing some code written with jQuery and some jQuery plugins using ExtJs. In the original code, I was able to use jQuery to make <img> objects draggable and clickable. Is there an Ext object which can be used to just display an image (like a thumbnail) and make it draggable and such?

tobiu
3 Mar 2010, 7:11 AM
welcome mikerthomsen,

i suggest an Ext.Element. Here is a direct-link to the api for it:
http://www.extjs.com/deploy/ext-3.1.1/docs/?class=Ext.Element

it shows some things you can do in the top section.


kind regards,
tobiu

mikerthomsen
3 Mar 2010, 8:36 AM
var image = new Ext.Element('img');
image.set({src: 'freedom_of_speech_demotivator.jpeg'});

causes firefox to raise this error:

Error: el is undefined
Source File: http://www.codemonkeyramblings.com/mt/mt-static/plugins/ImageGalleryExt/ext-all-debug.js
Line: 3856

Am I using set incorrectly?

tobiu
3 Mar 2010, 8:47 AM
the usage of set should be ok, the constructor not.

i would do it like this (example):



var div = ...

var img = document.createElement('IMG'); // create element
img.src = '../images/icons/delete.png';

div.parentNode.insertBefore(img, div); // insert it into the dom

var deleteIcon = Ext.get(img); // convert it to an ext.element



kind regards,
tobiu