I succeeds Sergio, as you said. Only update the application_helper.rb:
It was like this:
def jq_form()
fntn = <<CMD
<script src="/assets/jquery.serializejson.min.js"></script>
<script>
$("form[data-target]").submit(function(e){
e.preventDefault();
var curObj = jQuery(this).closest("form");
var opciones = curObj.serializeJSON({checkboxUncheckedValue:
"false"});
//alert(opciones);
var url = curObj.attr("action");
cl_state_form(curObj,false);
if (url) {
var destObj = jQuery(curObj.data("target"));
if (destObj) {
destObj.addClass('cl_loader');
destObj.load(url+"?" +
$.param(opciones),function(responseTxt,statusTxt,xhr){
if(statusTxt=="success") {
destObj.removeClass('cl_loader');
jQuery('.active-scaffold-component .load-embedded',
destObj).each(function(index, item) {
item = jQuery(item);
item.closest('.active-scaffold-component').load(item.attr('href'),
function() {
jQuery(this).trigger('as:element_updated');
});
});
};
if(statusTxt=="error")
cl_state_form(curObj,true);
});
destObj.removeClass('cl_loader');
};
};
cl_state_form(curObj,true);
return true;
});
//------------------
function cl_state_form(cl_form,state) {
if (state) {
jQuery('input[type=submit]', cl_form).removeAttr('disabled');
jQuery("input,select,textarea", cl_form).removeAttr('disabled');
} else {
jQuery('input[type=submit]', cl_form).attr('disabled',
'disabled');
jQuery("input,select,textarea", cl_form).attr('disabled',
'disabled');
}
}
</script>
CMD
fntn.html_safe()
end
On 20/02/2015 05:24 a.m., Sergio Cambra wrote:
So your view is replacing #contenido with this html:
<div class="active-scaffold-component" data-
refresh="/competencias?eid=12f36e04e6d224b74bb281454735bdc6&embedded=true"
id="as_12f36e04e6d224b74bb281454735bdc6-embedded"><div class="active-scaffold-
header"><h2><a class="load-embedded" data-remote="true"
href="/competencias?eid=12f36e04e6d224b74bb281454735bdc6&embedded=true">Competencias</a></h2></div></div>
Which includes a link to load an embedded scaffold.
ActiveScaffold loads embedded scaffolds with ActiveScaffold.load_embedded
function. This function is called everytime an action link finishes
successfully or as:element_updated event is triggered (usually when an item is
changed with ActiveScaffold.replace, ActiveScaffold.replace_html or
ActiveScaffold.append).
However you are loading html with destObj.load instead of using
ActiveScaffold, so you should trigger as:element_updated to trigger
ActiveScaffold listeners on your updated div.
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.