Here is something that I have been working on recently, and I thought I would share.
We have a news builder page that creates news items that appear under our News & Events section. These can also be linked under an Academic Department. In addition to this you can link the news item under a non-academic department. But this select list does not have set options. So I wanted a way for the user to quickly add a new non-academic department without having to leave the page, and without having to reload.
A folder is used as the create location, and jQuery is used to post both the asset builder for the folder, and for the news item.
View video of example: http://hhttp://www.zedsaid.com/__data/assets/file/0002/1100/Folder-Create-Ajax.mov
Use some jQuery POST code.
We have to use the .find function so that it will only return the div that we want, which contains some "Created" page information:
$("#createdFolder").append($(html).find("#ajaxResultFolder"));
We also have to update the select list, with our newly created option, making sure to add the newly created asset ID and the newly created asset name:
$("#non_academic").append("" + folderName + "");
A variable is set on the "Created" page with the new asset ID. This is brought in when we get our thank you results:
var folderItemId = %created_assetid%;
Make sure to add a "submit" button with our function:
[html]<input type="button" id="folderSave" onclick="createAssetFolder();" value="Save" />[/html]
And after all this, our new folder are created, and our selection list has been dynamicly updated with our new create location!
[attachment=295:Picture_2.png]
Remember that we are NOT nesting this asset builder into our News Item asset builder, we are only refering to it when we are posting, and sending it the nessisary data.
Hooray! Picture_2.png (2.29 KB)