Giter Site home page Giter Site logo

Comments (14)

kdzwinel avatar kdzwinel commented on July 27, 2024 2

Thanks @alexgorbatchev for a great plugin!

The bug occurs is in isValueAllowed method in core. When it's executed, values set via tagsItems are validated by checking if they exist in list = self.opts('filterItems') || self._suggestions || [] array. Unfortunately, this array is empty and all tags are recognized as invalid, that's why they won't render.

Simple workaround: Just set filterItems option to the same value as suggestions like this:

$('#trades_textarea').textext({
    plugins: 'autocomplete suggestions tags filter',
    tagsItems: selectedTags,
    filterItems: allTags,
    suggestions: allTags
})

from jquery-textext.

alexgorbatchev avatar alexgorbatchev commented on July 27, 2024

@evereq This looks like a bug. Have you looked at the code? Any idea what's happening?

from jquery-textext.

evereq avatar evereq commented on July 27, 2024

@alexgorbatchev ah, no sorry - too busy with other things :)

from jquery-textext.

ncreuschling avatar ncreuschling commented on July 27, 2024

I observe this behavior as well. I can't initialize a textarea with tagsItems together with the filter plugin.

from jquery-textext.

Amitesh avatar Amitesh commented on July 27, 2024

It occurred for me as well.
Here is sample code gist https://gist.github.com/2669286

I have removed "filter" plugin from it and It works.

@alexgorbatchev Great Work!

from jquery-textext.

katio avatar katio commented on July 27, 2024

I have the same problem. When you have filter and tags plugins, tagsItems and .addTags() don't work. I also tried using filter.enabled=false and then .addTags() without success.

@alexgorbatchev This js is cool. Thank you.

from jquery-textext.

cmeresse avatar cmeresse commented on July 27, 2024

Hello,

This works if you are using the suggestions plugin but if you are using ajax, you can not use this workaround. You have to call the ajax request "manually" to initialize the filterItems. And then I don't know what occurs if you add a new value into your backoffice? Will filterItems take it into account?

from jquery-textext.

stourpower avatar stourpower commented on July 27, 2024

I got around it by not using the built-in AJAX call function and instead, called the AJAX info into the page at the start on page load and then wrote it into the suggestions option - not the most sophisticated solution but it was good enough for what I needed...

$.get('url_of_Ajax', function(data){
    $('#id_selector').textext({
    plugins: 'autocomplete filter tags suggestions',
    suggestions: data
    });
});

from jquery-textext.

eek avatar eek commented on July 27, 2024

Had the same problem, my solution was to edit the source code and change from

p.addTags = function(tags)
{
    if(!tags || tags.length == 0)
        return;

    var self      = this,
        core      = self.core(),
        container = self.containerElement(),
        i, tag
        ;

    for(i = 0; i < tags.length; i++)
    {
        tag = tags[i];

        if(tag && self.isTagAllowed(tag))
            container.append(self.renderTag(tag));
    }

    self.updateFormCache();
    core.getFormData();
    core.invalidateBounds();
};

to

p.addTags = function(tags)
{
    if(!tags || tags.length == 0)
        return;

    var self      = this,
        core      = self.core(),
        container = self.containerElement(),
        i, tag
        ;

    for(i = 0; i < tags.length; i++)
    {
        tag = tags[i];

        if(tag)
            container.append(self.renderTag(tag));
    }

    self.updateFormCache();
    core.getFormData();
    core.invalidateBounds();
};

Allowance in addTags I think it's not so usefull. Works like a charm :)

from jquery-textext.

alariva avatar alariva commented on July 27, 2024

kdzwinel, the workaround seems clean. Have you got any idea on how to load the item list with AJAX ?

from jquery-textext.

kdzwinel avatar kdzwinel commented on July 27, 2024

@alariva Sorry, I haven't worked with this plugin since my last comment - I don't remember the details.

from jquery-textext.

fernao avatar fernao commented on July 27, 2024

raduamarie, thanks!

but this code needed to be commited to the code.

from jquery-textext.

 avatar commented on July 27, 2024

@eek can you please raise pull request, I think after that author can merge that into core, BTW nice work thanks your code works :)

from jquery-textext.

eek avatar eek commented on July 27, 2024

Done @fernao & @DhavalTailored but I don't think this plugin is maintained any more, we should ask for commit privileges or continue with a fork.

And maybe some design improvements (like Facebook has) and a React version which I can do and also a Vanilla JS one (jQuery is in decline from my point of view).

from jquery-textext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.