This support forum belongs to the Accordion Gallery Module.
Accordion has a bug tracker here: http://github.com/ipeychev/yui3-gallery/issues
| Page 1 of 2 | [ 15 posts ] | Go to page 1, 2 Next |
|
As result of investigating this issue, I decided to add a new feature - dynamic content loading.
Here is how it will work: 1. The item will have a new property - "dynamicLoad" - Boolean, false by default. 2. The Accordion will have new property - "contentLoader". It can be Function or Object. If function, it will be invoked before item expanding. It should load the content of the item and pass it back to Accordion (via event). If the value is Object, it should have the following properties: - "method" - must be Function, responsible for loading item's content. - "scope" - context in which to execute the function. - params - arbitrary value, will be passed directly to the function. 3. Before item expanding, Accordion will check if the content should be loaded dynamically. If true, it will set temporary content (simple "Loading..." message) and it will invoke the provided custom function. 4. Once it finishes the loading, it must fire the following event - "contentLoadingFinished". As parameters, it should pass the item and its new content. I am still testing this feature and it is not yet released, so this is the right moment to tell me what do you think about it. Iliyan |
|
Hi Iliyan,
Thanks for great support for this component. I am missing something here. I currently do something like this: accordion.on( "beforeItemExpand", function( attrs ){ var item; item = attrs.item; <io request for item> <io success handler writes new content into item's content box> I had some trouble, as mentioned by others, getting the dynamic content to show and in the end had to 'fix' the size of the item when expanded. Your proposed extension to the accordion requires additional configuration for the special case of dynamic content and I wondered whether your existing implementation could service this by the above code notifying the item that it has new content and consequently forcing it to resize according to the existing configuration rules eg. fixed, auto, stretch. Sorry if I have missed the point but just not sure why you need to do so much work. Alex |
|
alexlebek wrote: Hi Iliyan, Thanks for great support for this component. I am missing something here. I currently do something like this: accordion.on( "beforeItemExpand", function( attrs ){ var item; item = attrs.item; <io request for item> <io success handler writes new content into item's content box> I had some trouble, as mentioned by others, getting the dynamic content to show and in the end had to 'fix' the size of the item when expanded. Your proposed extension to the accordion requires additional configuration for the special case of dynamic content and I wondered whether your existing implementation could service this by the above code notifying the item that it has new content and consequently forcing it to resize according to the existing configuration rules eg. fixed, auto, stretch. Sorry if I have missed the point but just not sure why you need to do so much work. Alex Actually, dynamic content loading works fine when the value of "contentHeight" property is "fixed" or "stretch". It is pretty clear why - in these cases Accordion just doesn't care about the content. The height of the wrapper (Widget's body) is known and that's why we can change the content in each moment. This change will not involve changes to the other items in Accordion and especially these with "contentHeight" set to "stretch". The problems come when we are working with item(s), which "contentHeight" property is set to "auto". Here is what is going on when the user clicks on the header of such an item: 1. The Accordion calculates the height of the item. If this item still doesn't have content, its height will be 0px. If it has content, the height might be calculated to 16px or 116px - it doesn't matter. 2. Accordion fires "beforeItemExpand" event. [Right now the developer sends IO request in order to load the content from the server]. 3. Accordion collapses all items, which must be collapsed (if any). 4. Accordion increases or decreases the height of all items, marked as "stretched". 5. Accordion expands our item. Please note that the new content is still being transferred. [The request from the server completes and the developer sets the new content via "bodyContent" property]. In this case the whole procedure, described above was nothing, but waste of time, because the height of our item has changed and we must adjust not only its height, but also those of all expanded and "stretched" items. Not to mention that the request may complete in the middle of the above procedure. That makes the things a little bit complicated. One solution might be to lock the Accordion in such cases, but I am still thinking about it. Iliyan |
|
1. The Accordion calculates the height of the item. If this item still doesn't have content, its height will be 0px. If it has content, the height might be calculated to 16px or 116px - it doesn't matter.
2. Accordion fires "beforeItemExpand" event. [Right now the developer sends IO request in order to load the content from the server]. 3. Accordion collapses all items, which must be collapsed (if any). 4. Accordion increases or decreases the height of all items, marked as "stretched". 5. Accordion expands our item. Please note that the new content is still being transferred. [The request from the server completes and the developer sets the new content via "bodyContent" property]. Thanks for that explanation - I hadn't realised that ordering issue. Why can't the app mark the item in step 2 as 'locked' - so no size processing on it by accordion. When the app io success handler is called, and after it has inserted the new content, the success handler tells the accordion to resize the item according to stretch, auto etc. Is that horrible? Alex |
|
I'm using method of auto and it works fine...as long as it's wrapped in a <table><tr><td> data </td></tr></table>. All other methods cut the bottom off.
|
|
hpbrantley wrote: All other methods cut the bottom off. In case of "stretch" or "fixed" methods wrap the content in "div" element with the following styles: style="position: relative; height: 100%; overflow:auto;". Iliyan |
|
alexlebek wrote: Thanks for that explanation - I hadn't realised that ordering issue. Why can't the app mark the item in step 2 as 'locked' - so no size processing on it by accordion. When the app io success handler is called, and after it has inserted the new content, the success handler tells the accordion to resize the item according to stretch, auto etc. Is that horrible? Alex Locking is always an option, but let's try to do something else before: I did a small modification in Accordion and committed it in a separate branch - dynamic_load. I also added an example how to load content dynamically when "contentHeight" property is set to "auto". You can see it here. Save it to your computer and try it. I tested it in FF 3.5.8, Opera and Google Chrome. As you see, we subscribe to "beforeItemExpand" and set a temporary "Loading..." message as content. Then we load the real content asynchronously. In this example we are doing this by using Y.later, but you can replace it with a IO request. This is very close to what the user would expect from a real application. So, please try to use this approach in your application. Do not forget to use the modified version of Accordion (see <script> and <link> tags in the example), and not those from Yahoo! CDN. If this works, I will merge this change in the master branch. Iliyan |
|
Hi Iliyan,
Thanks for update - just trying out. First problem(I think) for me is that I do not replace the body of the accordion items as the items have substructure, only some of which, is dynamically loaded. Perhaps I am misunderstanding the dependency on this event with this latest update. My current use of the accordion replaces the relevant dynamic content through somediv.set('innerHTML', <my new content>) where 'somediv' is only part of the accordion item body. I suspect the 'bodyContentChange' event is not to fired using innerHTML but I don't see how to achieve this item partial update with item.set( "bodyContent", .... Is there a way to 'touch' the bodyContent attribute without updating it? Thanks Alex Have I missed something? |
|
Do you have an exact name for this sub-div or is it common among all the accordion item bodies?
|
|
I was playing around and this works. It may not be pretty or "correct" but it did work.
I started off by create an accordion using content from my database. How you do it is up to you but I used my db with my record id's because I have already written that. I created the items with bodyContent of: "<div id='item"+response[i].ACCORDION_ID+"'>text here with subdiv<div id='sub"+response[i].ACCORDION_ID+"'></div></div>" so it looks like <div id='item1'>text here with subdiv<div id='sub1'></div></div> When beforeItemExpand is called I just sent the item reference to function testFunction( item ) { Y.log(arguments.callee.name + ' called' ); dbID=item.get("dbID"); subDiv=Y.one("#sub"+dbID); subDiv.set("innerHTML","now subdiv with id "+dbID+" should have more content "); itemBody=item.get('bodyContent'); item.set('bodyContent', itemBody); } The end result is: <div id='item1'>text here with subdiv<div id='sub1'>now subdiv with id 1 should have more content</div></div> Like I said, in my case I had the record id handy so that's what I used. The short version of this is, you can use the same method as you were doing it: somediv.set() but afterwards read the bodyContent in and spit it right back out. It should have the content from your set() in it. My js is at http://www.brantleys.com/yui/js/yui_accordion4.js if you want to see it. When my host gets MySQL worked out where I can create VIEWS I'll have the mockup working. Hope this helps in some way. |
| Page 1 of 2 | [ 15 posts ] | Go to page 1, 2 Next |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group