AJAX Dialog Forms: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==TODO== Document all the components necessary to create a popup dialog using JQueryUI. ==Form Markup Requirements== Create separate PHP include file containing the markup ...") |
|||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 30: | Line 30: | ||
* <code>data-tid</code> attribute stores the content type value if it's needed by the JavaScript callback for the button. | * <code>data-tid</code> attribute stores the content type value if it's needed by the JavaScript callback for the button. | ||
* <code>data-op</code> attribute stores the operation when using <code>LITTLED.dialogEdit()</code> or a similar callback for the button. | * <code>data-op</code> attribute stores the operation when using <code>LITTLED.dialogEdit()</code> or a similar callback for the button. | ||
<syntaxhighlight lang="html4strict"> | <syntaxhighlight lang="html4strict" enclose="div"> | ||
<div class="submit-container"> | <div class="submit-container"> | ||
< | <button class="dlg-commit-btn" data-tid="<?=$input->site_section->id->value?>" data-op="delete">delete</button> | ||
< | <button class="dlg-cancel-btn">cancel</button> | ||
</div> | </div> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==AJAX Handler Script== | ==AJAX Handler Script== | ||
The text displayed as the title of the dialog is passed back as the value of <code>$json->label->value</code>. | The text displayed as the title of the dialog is passed back as the value of <code>$json->label->value</code>. | ||
==Editing records== | |||
===Overview=== | |||
* Specify handler with Sections CMS > Edit URI setting | |||
* Create an include file containing the form markup and place it in <code>_templates/forms/</code> in the content type's CMS directory. | |||
* Add the content type of the <code>cache_class</code>. | |||
* Update necessary <code>cache_class</code> routines. | |||
===Generic AJAX handler script=== | |||
* <code>[COMMON_LIB]_ajax/utils/edit_record.php</code> | |||
* Specify handler with Sections CMS > Edit URI setting | |||
* Define handler in <code>cache_class::load_json_content()</code> | |||
** Include the content type and optionally its corresponding filter class. | |||
** Within the <code>load_json_content()<code> routine create a case for the content type and the 'edit' operation. | |||
** Define any necessary logic in the content class's <code>save()</code> routine. | |||
[[Category:CMS Documentation]] | [[Category:CMS Documentation]] | ||
[[Category:JQuery/AJAX]] | |||
Latest revision as of 18:47, 21 October 2012
TODO[edit]
Document all the components necessary to create a popup dialog using JQueryUI.
Form Markup Requirements[edit]
Create separate PHP include file containing the markup for the FORM element that will be inserted into the dialog.
FORM element[edit]
Has no parent DIV element.
id="dialog-edit-form"
<form id="dialog-edit-form"> </form>
Contains hidden input storing action property, and optionally record id and content type id.
<input type="hidden" name="<?=P_COMMIT?>" value="1" /> <input type="hidden" name="<?=$input->id->param?>" value="<?=$input->id->value?>" /> <input type="hidden" name="<?=$input->site_section->id->param?>" value="<?=$input->site_section->id->value?>" />
Submit buttons. JavaScript handlers will be assigned to the buttons after the FORM element has been added to the DOM.
data-tidattribute stores the content type value if it's needed by the JavaScript callback for the button.data-opattribute stores the operation when usingLITTLED.dialogEdit()or a similar callback for the button.
<div class="submit-container"> <button class="dlg-commit-btn" data-tid="<?=$input->site_section->id->value?>" data-op="delete">delete</button> <button class="dlg-cancel-btn">cancel</button> </div>
AJAX Handler Script[edit]
The text displayed as the title of the dialog is passed back as the value of $json->label->value.
Editing records[edit]
Overview[edit]
- Specify handler with Sections CMS > Edit URI setting
- Create an include file containing the form markup and place it in
_templates/forms/in the content type's CMS directory. - Add the content type of the
cache_class. - Update necessary
cache_classroutines.
Generic AJAX handler script[edit]
[COMMON_LIB]_ajax/utils/edit_record.php- Specify handler with Sections CMS > Edit URI setting
- Define handler in
cache_class::load_json_content()- Include the content type and optionally its corresponding filter class.
- Within the
load_json_content()routine create a case for the content type and the 'edit' operation. - Define any necessary logic in the content class's
save()routine.