Zend Framework

Dijit parsing before store creation results in FilteringSelect and ComboBox dijits not working properly.

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.7.6
  • Fix Version/s: None
  • Component/s: Zend_Form, Zend_View
  • Labels:
    None

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:

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:

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:

$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'           => 'http://foo.com/userautocomplete',
				        'requestMethod' => 'get',
				    ),
			));
			
$form->addElement( $author_fld );

Issue Links

Activity

Hide
Denis Baklikov added a comment -

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?

Show
Denis Baklikov added a comment - 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?

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: