Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
## Radiant CMS hook to include ajax-save.js in admin edit views # can be put in the `activate` method of an extension Admin::PageController.class_eval do before_filter :enable_ajax_save, :only => [:edit] protected def enable_ajax_save include_javascript 'ajax-save.js' end end ## public/javascripts/ajax-save.js -- unobtrusive Ajax post on "save and continue" [javascript] // works with page_attachments extension (latest version): // http://dev.radiantcms.org/svn/radiant/trunk/extensions/page_attachments document.observe("dom:loaded", function() { when('form[method=post]', function(form) { var contButton = false, lockField = $('page_lock_version'), attachments = $('attachments') $(form['continue']).observe('click', function() { contButton = true }) form.observe('submit', function(e) { if (contButton && !this.down('input[type=file]')) { form.request({ onFailure: function() { alert("Ajax saving failed!") }, onSuccess: function() { lockField.setValue(parseInt(lockField.getValue()) + 1) if (attachments) when(attachments.select('input[name="page[delete_attachments][]"]'), function(inputs) { inputs.invoke('remove') attachments.down('.notice').remove() }) } }) contButton = false e.stop() } }) }) })
From the Design Piracy series on my blog: