[Dojo-interest] this.store is undefined

Dustin Machi dmachi at dojotoolkit.org
Fri Jul 24 07:37:08 EDT 2009


Its hard to say what the correct answer is without knowing where the  
store is availalbe.  If it was declared globally, then you can just  
access store.getValue().  You could also pass it into itemAccept using  
partial (or hitch)...something like htis:

checkItemAcceptance: dojo.partial(itemAccept, store),

then your itemAccept method would look like:

function itemAccept(store, target, source) {
	/* use store in here */
}

Dustin

On Jul 23, 2009, at 10:05 PM, Jean-Rubin Leonard wrote:

> Hi Dustin,
> thanks for a quick reply.
> I understand about the scope but I really have no idea how to work  
> around it.
> Here's where I called itemAccept originally:
> 		var treeScenarios = new dijit.Tree({id:"treeScenarios",
> persist:"false",model:treeModel,
> dndController 
> :"dijit 
> ._tree 
> .dndSource 
> ",betweenThreshold 
> :"5 
> ",deferItemLoadingUntilExpand:"true",checkItemAcceptance:itemAccept});
>
> and that's what I'm doing now:
> 		var treeScenarios = new dijit.Tree({id:"treeScenarios",
> persist:"false",model:treeModel,
> dndController 
> :"dijit 
> ._tree 
> .dndSource 
> ",betweenThreshold 
> :"5 
> ",deferItemLoadingUntilExpand 
> :"true",checkItemAcceptance:dojo.hitch(this,itemAccept)});
> with the same results.
>
> what other would there be for me to access the store. Thanks for  
> your support.
> JR
> On Thu, Jul 23, 2009 at 9:03 PM, Dustin  
> Machi<dmachi at dojotoolkit.org> wrote:
>> 'this' is not in the scope you are expecting. you'll need to access
>> the store via some other ref or use a closure/hitch to take care of
>> it. for example pass:
>>
>> dojo.hitch(this,itemAccept) instead if ItemAccept
>>
>> Dustin Machi
>> http://sitepen.com
>> http://www.dojotoolkit.org
>>
>> On Jul 23, 2009, at 8:52 PM, Jean-Rubin Leonard <jrleonard at gmail.com>
>> wrote:
>>
>>> Hi,
>>> I am trying to create a checkItemAcceptance function. I have the
>>> following function but whenever I run it, I get the "this.store is
>>> undefined" error. I am stuck. Anyone can help?
>>> This is my function.
>>> Any help is welcome.
>>> JR
>>> function itemAccept(target, source) {
>>>    var targetNode = dijit.getEnclosingWidget(target).item;
>>>
>>>    // There is no item connected with the root
>>>    if (! targetNode) {
>>>    return false;
>>>    }
>>>
>>>    var targetType = this.store.getValue(targetNode.item,  
>>> "node_type");
>>>
>>>    switch(targetType)
>>>    {
>>>    case "Cost center group":
>>>        if(dojo.hasClass( source.item, "Portfolio") ){
>>>            return true;
>>>        }else
>>>        return false;
>>>
>>>    default:
>>>    return false;
>>>    }
>>>
>>> }
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at mail.dojotoolkit.org
>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at mail.dojotoolkit.org
>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



More information about the Dojo-interest mailing list