Results 1 to 6 of 6

Thread: Question about dynamically access and set configurations of an object

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    104
    Vote Rating
    1
      0  

    Default Question about dynamically access and set configurations of an object

    Hi,

    How can I dynamically access and set/reset configurations of an object, for instance access and set revert of an draggable object.

    Thanks!

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,675
    Vote Rating
    886
      0  

    Default

    In the case of revert, you can just change the property on the object:

    Code:
    foo.revert = true;
    Evan Trimboli
    Twitter - @evantrimboli

  3. #3
    Ext User
    Join Date
    Aug 2010
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Well...is this the general way to change properties at run-time?

    Why this code does not work? Am I forgetting something? (SEE "THIS DOES NOT WORK" BELOW)

    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
    <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="extjs/ext-all.js"></script>
    <script language=javascript>

    var Obj = null;

    function Change() {
    Obj.setWidth(200); // <-----this works!!!
    Obj.scale='large'; // <-----THIS DOES NOT WORK!!!!
    };

    Ext.onReady(function(){
    Obj=new Ext.Button({ id:'Teste',renderTo: 'container',text:'Confirmar',scale:'small'});
    });

    </script>
    <div id=container></div>
    <button onclick=Change()>Change</button>

  4. #4
    Ext User
    Join Date
    Aug 2010
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Anybody there?

    I think this is a quite basic question that anyone could answer...or am I wrong and ExtJs is a little bit more misterious that I thought?

  5. #5
    Ext User
    Join Date
    Aug 2010
    Posts
    3
    Vote Rating
    0
      0  

    Default

    This message seems to report the same problem:

    http://www.sencha.com/forum/showthre...roperty+object

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,675
    Vote Rating
    886
      0  

    Default

    FYI this isn't the Ext JS forums, these are the ones for Touch, but the same thing applies, so:

    Javascript doesn't have properties (it does in some implementations but not all). As such, setting a property on an object doesn't ~do~ anything, other than just setting the value.

    In some cases, like the one I listed above with revert, you can do that. This is because at runtime, each time the draggable is moved, it checks

    Code:
    if(this.revert){....}
    So setting this property at runtime will have some affect.

    If we take your case, setting the title does nothing. Why? Because you're just setting a property on an object. By setting the title property, you're expecting it to go and update the DOM, which it won't. As such, there's a method called setTitle you can use.

    We're looking at better ways of documenting these properties and indicating which can be changed at runtime and which can't.
    Evan Trimboli
    Twitter - @evantrimboli

Similar Threads

  1. Object reference not set to an instance of an object
    By johnjalani in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 28 Jan 2009, 8:33 AM
  2. Cannot access date object
    By businessman332211 in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 19 Nov 2008, 7:44 AM
  3. Can't access object method
    By cnkt in forum Ext 2.x: Help & Discussion
    Replies: 22
    Last Post: 24 Sep 2008, 7:23 AM
  4. Access an Tree.TreePanel object and Ext. Panel object outside Ext.onReady()
    By ampusjnair in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 13 Jun 2008, 4:08 AM
  5. How to access (or get) an object
    By kailf in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 16 Aug 2007, 3:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •