Code Monkey home page Code Monkey logo

Comments (19)

KyleDFulton avatar KyleDFulton commented on May 22, 2024

also, I have two autocomplete inputs on the same page.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

What do you mean by 'init is not called'? What init are you referring to?

I think the issue is caused by the fact that you are passing a reactive value User into the template. I don't think I've tested this behavior with autocomplete, and Blaze works in weird ways. It's probably not caused by the two inputs.

Could you create a demo app so that I can debug this? Just factor out the part with the autocomplete and provide some way of changing the user value. Meanwhile you can test it or use as a workaround without value=User and it should work normally. If that fixes it, then this is indeed what we'll need to dig into further.

If that's not the problem, then I don't understand what the following means; could you explain it more concisely?

the second set of constructors are not invoked and the previously constructed and initialized/rendered autocomplete inputs are hooked up

from meteor-autocomplete.

KyleDFulton avatar KyleDFulton commented on May 22, 2024

Thanks a lot.

I am referring to the init function in template.coffee that gets hooked up to the render callback.

# Set nodes on render
init = ->
  console.log('AutoComplete inited'); // I added this
  @data.ac.element = @firstNode
  @data.ac.$element = $(@firstNode)
  @data.ac.tmplInst = this

Template.inputAutocomplete.rendered = init
Template.textareaAutocomplete.rendered = init

the inputAutocomplete template is nor rendered the second time. I have the editor bound to a reactive datasource. After I insert the record, meteor keeps the client local value. Everything gets hooked up. After mongo accepts the value, it pushes the server copy of the record back to the client and tries to re-create the autocompletes, but the render never gets called.
.
I will try removing the value=User and see. And I will deploy my app to meteor and give you a url.

Thanks a lot.

Kyle

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

The render is only called once in Blaze (meteor/meteor#2001 and meteor/meteor#2010). We don't have a good way to deal with reactive updates to data passed to the rendered callback right now.

I recommend you take reactive variables out of the autocomplete instantiation for now, until Meteor resolves some issues that allow us to use them properly in UI components.

P.S. Please fence in your code blocks as I have done for you. Makes things much easier to read.

from meteor-autocomplete.

KyleDFulton avatar KyleDFulton commented on May 22, 2024

I refactored to handle the db insertion asynchronously and only put the record into edit mode after the callback was invoked. That took care of it. Thanks.

One minor suggestion to allow better reuse of functions. please pass the rule along with the doc when invoking the rule callback:

rule.callback?(doc, rule) # Notify that the item has been selected

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

I'm going to keep this issue open so that we can see if other users have issues passing reactive variables to autocomplete and to keep it on the list of things to fix.

from meteor-autocomplete.

KyleDFulton avatar KyleDFulton commented on May 22, 2024

and also the element for context.

That is fine -- your issues ;-).

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

Mind putting the callback suggestion in a separate issue? It's going to get lost in this thread for sure.

from meteor-autocomplete.

KyleDFulton avatar KyleDFulton commented on May 22, 2024

will do

from meteor-autocomplete.

Neobii avatar Neobii commented on May 22, 2024

It seems that if you just change the data-context AutoComplete is in, it causes autocomplete to stop working.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

Yep, we don't support dynamic changes to data contexts right now. Hopefully this will be fixed with updates to Blaze.

In the meantime, mind letting me know what you're changing in the data context?

from meteor-autocomplete.

Neobii avatar Neobii commented on May 22, 2024

I'm not actually using the data for anything in the autocomplete.

{{#with object}}
<input type="text" name="utilityType"/>
<input type="date" name="expDate"/>
{{> selectUtilitySuppliers}} <!-- this is the template with the autocomplete form field  -->
{{/with}}

So, on the 'change' events, I update the data instead of having save buttons that both dismiss the form and save all the form fields at once.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

@Neobii, can you show the contents of the selectUtilitySuppliers template in addition to its parent? What are you passing in as arguments to the autocomplete helper?

https://meteor.hackpad.com/Blaze-Proposals-for-v0.2-hsd54WPJmDV is tracking API changes that may be able to help us resolve this problem, whatever its cause.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

@Neobii, can you confirm that when it "stops working", it shows the same errors as posted in #35?

from meteor-autocomplete.

Neobii avatar Neobii commented on May 22, 2024

It doesn't have that error, but I'm going to try to pass in the data context in the helper like {{> autocompleteTemplate dataContextINeed}} instead of doing {{#with dataContextNeeded}}{{> autocompleteTemplate}}{{/with}} to see if that makes it work.

from meteor-autocomplete.

Neobii avatar Neobii commented on May 22, 2024

So, that doesn't work, the only thing that happens is the autocomplete template doesn't show up. I'll make a reproduction for you.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

@Neobii and @KyleDFulton, the latest commit c79402f gives a workaround for this until the new Blaze Component API is released. Can you try it with your app and let me know if the errors persist?

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

Although this is fixed in 0.4.4, I'm keeping this issue open so we can have a better long term solution that doesn't involve re-rendering.

However, it doesn't even appear that things are really "re-rendering" in Blaze. For example, the contents of the input are preserved even in the example app given in #35 across a re-render.

from meteor-autocomplete.

mizzao avatar mizzao commented on May 22, 2024

@Neobii and @KyleDFulton: This issue is fixed on the blaze-refactor branch for Meteor 0.8.3. Autocomplete components now support changing all inputs reactively except for settings.

Please give it a try and feel free to comment in this thread if there are still issues.

from meteor-autocomplete.

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.