Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » How do I refresh a form field in the CMS after saving?

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

Page: 1
Go to End
Author Topic: 497 Views
  • micmania1
    Avatar
    Community Member
    7 Posts

    How do I refresh a form field in the CMS after saving? Link to this post

    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.

  • frankmullenger
    Avatar
    Forum Moderator
    51 Posts

    Re: How do I refresh a form field in the CMS after saving? Link to this post

    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).

  • micmania1
    Avatar
    Community Member
    7 Posts

    Re: How do I refresh a form field in the CMS after saving? Link to this post

    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...
    }
    });
    });

    497 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.