Creating a flexicontent plugin with jquery or mootools

More
11 years 9 months ago #27069 by jdc18
Hi

I am doing a text field plugin that has an autocomplete function with obviously Javascript. Which do you recommend jquery or mootools, specially since I am going to clean up and give back the code. I do not intend to just give it to my client.

I like more jquery, and have more experience with it.

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #27070 by jdc18
I just checked the code and there is a jquery autocomplete plugin already, lol. Is this a part of joomla or flexicontent.

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #27071 by ggppdk
FLEXIcontent includes JQuery auto-complete js files, and loads them in item editing form.

Joomla itself comes with mootools only.


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #27077 by jdc18
The version of jquery autocomplete is the deprecated one right? New versions of autocomplete are part of the jquery-ui.

If I want to add an autocomplete on a text that loads from sql query I have to add my own function or it is a function I can enable on flexicontent.

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #27079 by ggppdk
I will tell you how to call a JSON-outputing function inside you custom FLEXIcontent plugin for getting the data:

Code:
$plg = "myfield"; // for calling: plugins/flexicontent_fields/myfield.php $act = "getData" // for calling: json-outputing function getData() inside myfield.php // the above function should JSON encode an array: // $arr[0] = array('id'=>15, 'name'=>'some'); // $arr[1] = array('id'=>11, 'name'=>'other'); // $arr[2] = array('id'=>37, 'name'=>'word'); $tagid = "myformfield"; // ID of HTML Tag in which you will use auto-complete $resetFunc = "resetMyfield"; // JS funtion that resets the above field $this->document->addScriptDeclaration(" jQuery(document).ready(function () { jQuery(\"".$tagid."\").autocomplete(\"".JURI::base()."index.php?option=com_flexicontent&task=doplgact&act=".$act."&".JUtility::getToken()."=1\", { width: 260, max: 100, matchContains: false, mustMatch: false, selectFirst: false, dataType: \"json\", parse: function(data) { return jQuery.map(data, function(row) { return { data: row, value: row.name, result: row.name }; }); }, formatItem: function(row) { return row.name; } }).result(function(e, row) { jQuery(\"".$tagid."\").attr('datid',row.id); jQuery(\"".$tagid."\").attr('datname',row.name); addToList(row.id, row.name); }).keydown(function(event) { if(event.keyCode==13) { ".$resetFunc."(); return false; } }); function ".$resetFunc."() { jQuery(\"".$tagid."\").attr('datid',0); jQuery(\"".$tagid."\").attr('datname',''); jQuery(\"".$tagid."\").attr('value',''); } }); ");

I have not test the above, it will need corrections. If you use and correct the code you can post here.
Please don't ask me to test any code. The above code i a start if you want to create a Custom FLEXIcontent field that will :
1. Use jQuery autocomplete
2. Retrieve the autocomplete data via Ajax

If you don't need to retrieve autocomplete data via AJAX, then use a JS array. Read more in jQuery autocomplete documentation

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 9 months ago #27207 by jdc18
Thanks I had a similar idea.
My only question is about this line,
Code:
\"".JURI::base()."index.php?option=com_flexicontent&task=doplgact&act=".$act."&".JUtility::getToken()."=1\"
I understand how the jquery autocomplete works, but the task doplgact in this line I dont understand. I am still a little bit unclear on how to use json and ajax to retrieve values with the joomla framework. I was reading these docs.joomla.org/Xml-rpc_changes_in_Joomla!_1.6 .

I know I should create a php file that will consult the data from my database. So I think that task of doplagct is calling the file right?

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.290 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline