[SOLVED] How to obtain consistency of an element that depends by another?

Wrap that whole thing in this:

Code:
window.addEvent('fabrik.loaded', function() {
   /// all existing code goes here
});

-- hugh
 
I am working on a new site.

In the new site I use
Code:
var nome_curriculum_count = document.id('fabrik_soggetti___Curriculum_delete_span') ? document.id('fabrik_soggetti___Curriculum_delete_span').getElements('a').length : 0;

(I only changed from fabrik_nominativi to fabrik_soggetti) but it doesn't work: even if there is a name in fabrik_soggetti___Curriculum, nome_curriculum_count is 0.

Something is changed in new version 3.4 of Fabrik or in some update from Github?
 
Did you examine the DOM structure in your browser?

We are moving away from using ID's with postfixes to identify things like this, to using data-role="foo" (HTML5). So the delete button now looks like this:

Code:
<span class="fabrikUploadDelete" data-role="delete_span">
<button class="btn button" data-file="/uploads/fab_uploads/simple_upload/incaseoffire__1_.jpg" data-join-pk-val="">Delete</button>
<a href="..." title="">...</a>
</span>

... so to select it, you'll need to find the delete_span data-role (or the fabrikUploadDelete class) within the main fb_el_yourtable___yourelement container (all elements are in a container with a class that has the full element name prepended with fb_el_).

So this would get you that length ...

Code:
var nome_curriculum_count document.getElements('.fb_el_fabrik_soggetti___Curriculum .fabrikUploadDelete a').length;

Also, since then, the recommended way to delay running something until Fabrik is loaded is to use requirejs, rather than window.addEvent ...

Code:
requirejs(['fab/fabrik'], function() {
   // your code here
});

   -- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top