Input Elements In Repeater Disabled

Hi guys!

I’m creating a form where filmmakers enter their film credits. I’d like the filmmakers to have the ability to click on the “+ button” to add additional credits and “-“ to remove credits.

I have two collections:
→ “Credits” (list of credits for dropdown)
→ “Credit Names” (to save input of selected credit, full name, and Instagram handle)

I followed this example and tried to customize it to my needs, but m y input elements are disabled:
https://www.wix.com/corvid/forum/tips-tutorials-examples/example-input-repeaters

I also looked into these resources:
https://www.wix.com/corvid/forum/tips-tutorials-examples/example-todomvc
https://www.wix.com/corvid/reference/$w.Repeater.html

Is there something wrong with or missing in my code?

// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from "wix-data";

let credits = [];

$w.onReady(async function () {

 let resCredits = await wixData.query("Credits").find();
 let resItems = resCredits.items;
    credits = resItems.map((item) => { return { "label": item.title, "value": item.title } });

    $w("#creditsRepeater").onItemReady(($item, itemData, index) => {
 
        $item('#creditsDropdown').options = credits;
        $item('#creditsDropdown').value = itemData.creditType;

        $item("#addCreditsButton").onClick(async (event) => {
 await $item('#creditNamesDataset').save();
 
        });
    });
})

export async function addCreditButton_click(event) {

 await $w('#creditNamesDataset').new();
 let item = $w("#creditNamesDataset").getCurrentItem();

    $w("#creditsRepeater").forEachItem(($item, itemData, index) => {

 if (item._id === itemData._id) {
            console.log("new", item._id);

            $item('#creditsDropdown').show();
            $item('#ceditNameInput').show();
            $item('#instagramInput').show();
        }
    });
}

async function addNewOnEmpty() {
 if ($w("#creditNamesDataset").getTotalCount() === 0) {
 await $w('#creditNamesDataset').new();
 let item = $w("#creditNamesDataset").getCurrentItem();

        $w("#creditsRepeater").forItems([item._id], ($item, itemData, index) => {
 
            $item('#creditsDropdown').options = credits;
            $item('#creditsDropdown').value = itemData.creditType;

            $item('#creditsDropdown').show();
            $item('#ceditNameInput').show();
            $item('#instagramInput').show();
 
        });
    }
}

My page: https://www.bayareafilmmakers-arthouse.com/film-metadata

From what I see…

  • You don’t have the addCreditButton connected to an onClick() event handler.

  • You don’t have the Repeater connected to a Dataset (Connector). Also, don’t forget to connect the item elements to the appropriate fields in the Dataset.

There might be other issues as well, but these are the first that I found.

Thank you Yisrael!!

It seems to be working, but now I’m getting this error:
“Wix code SDK error: The “onItemReady” function of “creditsRepeater” threw the following error: $item(…).onClick is not a function”

Also, the “-“ button is not doing anything. I’m not finding the code for the delete button in this example: https://www.wix.com/corvid/forum/tips-tutorials-examples/example-input-repeaters

My page: https://www.bayareafilmmakers-arthouse.com/film-metadata

You are getting the error " $item(…).onClick is not a function” because #addCreditsButton is an element that is not in the Repeater. Remove these lines from the onItemReady() function:

$item("#addCreditsButton").onClick(async (event) => {
    await $item('#creditNamesDataset').save();
 });

You don’t need these lines because you already have addCreditButton_click_1(event);

The “-” button doesn’t work since you don’t have an onClick() event handle for it.

Hi Yisrael,

Thank you again for your answer!

I removed the code you mentioned. I also connected the “-“ button to the dataset using the “delete” button setting.

When I save and preview, everything seems to work now.

However, when I publish and try it on the website page, the dropdown is disabled and I cannot add more than one new repeater item.

I’m not sure if it is related, but in preview mode, I’m getting this message in the Developer Console:

Page: https://www.bayareafilmmakers-arthouse.com/film-metadata

Did ou sync your sandbox (Preview) database with the Live database?

Thank you! I synced it and the dropdown works now!

However, I’m still having the issue of not being able to add more than one repeater item when published. It looks like the “+” button is disable after the first click?

@bayareafilmmakerarth I was able to add a bunch of new items - seems to work fine.

That’s strange, it’s working in public mode for you?

I tried on two different computers and it still doesn’t seem to work for me…

It works now! I actually did just need to fix the collection settings to allow anyone to edit. Thank you so much for your help!