Issues

ZF-6873: Dijit parsing before store creation results in FilteringSelect and ComboBox dijits not working properly.

Issue Type: Bug Created: 2009-06-01T07:16:17.000+0000 Last Updated: 2012-05-09T16:12:22.000+0000 Status: Open Fix version(s): Reporter: Denis Baklikov (denis.baklikov) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Dojo

Related issues: - ZF-6018

Attachments:

Description

If a ComboBox or FilteringSelect element is parsed before its store has been instantiated, it won't use the store. In previous versions of ZF, the ordering of dojo.addOnLoad functions put store creation before dijit parsing. In 1.7.6, dijits are parsed first (I believe this is because of [#ZF-4587]). This means forms using ComboBoxes and FilteringSelects which used to work in 1.7.5 no longer work correctly.

The following code, produced by 1.7.6 does not work:

<pre class="highlight">
dojo.require("custom.AutocompleteReadStore");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Form");
dojo.require("dojo.parser");
dojo.addOnLoad(function() {
    dojo.forEach(zendDijits, function(info) {
        var n = dojo.byId(info.id);
        if (null != n) {
            dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
        }
    });
    dojo.parser.parse();
});
dojo.addOnLoad(function() {
    autocompleter = new custom.AutocompleteReadStore({"url":"http:\/\/foo.com\/userautocomplete","requestMethod":"get"});
});
var autocompleter;
var zendDijits = [{"id":"author_id","params":{"store":"autocompleter","dojoType":"dijit.form.FilteringSelect",{"id":"the_form","params":{"dojoType":"dijit.form.Form"];

The following, created by 1.7.5, however, does work:

<pre class="highlight">
dojo.require("custom.AutocompleteReadStore");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Form");
dojo.require("dojo.parser");
dojo.addOnLoad(function() {
    autocompleter = new custom.AutocompleteReadStore({"url":"http:\/\/foo.com\/userautocomplete","requestMethod":"get"});
});
dojo.addOnLoad(function() {
    dojo.forEach(zendDijits, function(info) {
        var n = dojo.byId(info.id);
        if (null != n) {
            dojo.attr(n, dojo.mixin({ id: info.id }, info.params));
        }
    });
    dojo.parser.parse();
});
var autocompleter;
var zendDijits = [{"id":"author_id","params":{"store":"autocompleter","dojoType":"dijit.form.FilteringSelect",{"id":"the_form","params":{"dojoType":"dijit.form.Form"];

Both examples result from the following addition to a Zend_Dojo_Form:

<pre class="highlight">
$author_fld = new Zend_Dojo_Form_Element_FilteringSelect( 
                'author_id',
                array(
                    'label'     => 'Author:',
                
                    // The javascript identifier for the data store:
                    'storeId'   => 'autocompleter',
                
                    // The class type for the data store:
                    'storeType' => 'custom.AutocompleteReadStore',
                
                    // Parameters to use when initializing the data store:
                    'storeParams' => array(
                        'url'           => '<a href="http://foo.com/userautocomplete">http://foo.com/userautocomplete</a>',
                        'requestMethod' => 'get',
                    ),
            ));
            
$form->addElement( $author_fld );

Comments

Posted by Denis Baklikov (denis.baklikov) on 2009-06-01T07:38:14.000+0000

Hello,

I have found out that issue appears when DOJO loads from CDN. It works OK, if we are using local version.

I have modified code, by adding to store initialization to addOnLoad method, and my website start to work properly.

Could you please check it?

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts