Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How do I refresh a form field in the CMS after saving?


Go to End


3 Posts   2110 Views

Avatar
micmania1

Community Member, 9 Posts

17 January 2013 at 1:11am

Edited: 17/01/2013 1:47am

I've created a custom field which I'm trying to use in the CMS, but I can't get it to render correctly after saving a page.

When it initially loads, I use Requirements::javascript() calls to include my required files. This works, but when the form refreshes after a save, the field loses its styles.

Is there a way I can style the fields (execute my js) after the form refreshes?

I've read the javascript documentation here but i can't seem to find a solution.

Any help would be greatly appreciated.

Avatar
frankmullenger

Forum Moderator, 53 Posts

17 January 2013 at 9:30am

If you are not already you might like to use entwine for your javascript. Also, iirc, I had some problems with styles being applied after AJAX load of pages in ModelAdmin (SS3.0.2 I think) - simply because when the page was being retrieved via AJAX the HTML markup changed very slightly (missed a wrapping div I think).

Avatar
micmania1

Community Member, 9 Posts

1 February 2013 at 12:29am

Thanks for the reply.

I was struggling with how to do it with entwine.

For anybody with the same issue, the solution was:

jQuery(document).ready(function($)
{
    $(SELECTOR).entwine({
        onmatch: function ()
        {
            // load form field...
        }
    });
});