Custom Element plugin not call JS

ovillasmil

New Member
Hi,

I wonder if you can help me and guide me to where the problem is.

I created a custom plugin based on the Slider demo.

Following are the files and folders:
*****
Folder: plugin / fabrik_element / tristate

PHP: class plgFabrik_ElementTristate
function elementJavascript --> return new fbTristate
in the HTML of the element, there is a onclick="changeValue()" call --> console error: changeValue is not defined

Min-JS, JS: class fbTristate
in function initialize, I'm executing a call to "alert("asasasa")" --> is not executed
created a function changeValue, executing "location.reload(true)"
*****

Can you let me know, why the alert is not executed when initialize? and why changeValue is not executed from onclick event in the element?

Thanks in advance
 
I can't answer that without seeing the code.

If you want to attach the plugin folder as a ZIP, I'll take a look.

-- hugh
 
OK, I've fixed a few issues, and added enough to get you pointed in the right direction.

Basically, if you want to have the element be 'active' in a List view, you have to provide a plugin-list.js as well as plugin.js (which is only for form view).

A better element to have started from owuld probably have been "rating", which allows for clicking in a list.

Before I hand you the code back ... is the idea of this element to have a three way clickable selection, which just cycles through the selections? Using either icons, or text?

That sounds moderately useful, and I can think of quite a few other folk who might like that as a quick "status change" element type.

So I'd be happy to help, assuming you don't mind me adding the plugin to github and making it a part of Fabrik.

If we do that, I'd also like to make it a little more generic, so it's "N way" rather than "3 way', i.e. we make the number of states changeable. Using a 'repeat control' on the backend settings (rather like the dropdown or checkbox elements). I'd also like to make the values settable.

So ... let me know if you want to put this in github, and I'll go ahead and add it to the project. That'll also make it a lot easier for us to work on the code together, as you can just fork the main Fabrik github repo, merge any changes I make, and send push requests for any changes you make (which I can fold back in to the master with one mouse click).

-- hugh
 
Hi Hugh,

Thanks for your help.

Of course I would like to help the community. Go ahead and make it part of fabrik.

Just one note here: the idea of the element I have is only for a Boolean element (that's the reason for a tiny int)

The "3rd" status (icon or text) exist only in the "search mode" of the element. From my point of view it is useful only in this sense. We have 2 examples: one in Joomla!, the publish-unpublish clickable icon in the list, the second in Fabrik list: the Sort icon in the column title.

In the 2 examples above, the 3rd value is the "Please select" or "Unsorted" values. What I call "Show All". Ok, the sort column is not the best example, just using it to show my point: 2 useful values, and the 3rd to say only "no value is selected yet", but it doesn't mean the DB column will be populated with it.

What you understood (probably because what I attached is incomplete), a N statuses element (text or icons) probably will be as you said "moderatly useful", because we are creating a Picklist like element (but without the drop down list!). I would not recommend that, because if the user have to select the last one, after seeing 15 icons, will be frustrating and a bad user experience.

In any case, somebody will find a good use case, for sure.

If you will create the control for fabrik, think about an N+1 element, where the last status "+1" will be the text/icon configured for that "search all" in the search section.

At the end, this N+1 element will work for me too, in my case is obvious N=2

Thanks again, I will see what is inside that "rating" plugin!
 
Hi back,

Just one more note I believe is important for the plugin :) : it have to update/refresh "inline", if not, will not be useful. If the page refresh completely, will be a problem.

regards,
O
 
Hi Hugh,

I was able to configure the plugin in the list using images, thanks for the help.

This thread can be closed then. My problem now is in other new thread related to this plugin, the checkbox in the form is not "submitted".

Bye
O
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top