Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm working on an inline references module that will load referenced node content and allow pop-up editing of that content, but I'm having trouble firing js after a new node is created and then referenced. Since I can't control order of execution for events bound to popups_form_success, it would be best for me if popups: add and reference triggered .change() after updating a reference value and I bound my functionality to the change event. Other modules reacting off of a nodereference field value changing would benefit from this as well.
Comment | File | Size | Author |
---|---|---|---|
#8 | popups_reference.patch | 713 bytes | ulechka |
#7 | trigger_change.patch | 1.89 KB | cYu |
#3 | trigger_change.patch | 1.71 KB | cYu |
trigger_change.patch | 1.56 KB | cYu |
Comments
Comment #1
cYu CreditAttribution: cYu commentedBah, I guess it isn't as easy as I was trying to make it. When .find() finds nothing and then .end().change() is fired it will throw JS errors. My jquery chops are a bit lacking, so I don't know the best way of making this happen conditionally.
Comment #2
cYu CreditAttribution: cYu commentedComment #3
cYu CreditAttribution: cYu commentedIs something like this sensible?
Comment #4
starbow CreditAttribution: starbow commentedInteresting.
Can't you just bind an onChange trigger to the elements directly in your custom code?
Comment #5
cYu CreditAttribution: cYu commentedYes, my code is bound to change() but without this patch it is not fired after a new nodereference is created in popups: add and reference. I thought it would, but doing something like
to change the input's value will not fire the change event, which is what this patch would explicitly do after form element values are set.
Comment #6
starbow CreditAttribution: starbow commentedOk, that totally makes sense.
If you can change the patch to be against 2.0-alpha1 (the 1.0 branch is closed to new features), and try extracting
into a stand alone function, to keep the code neat, I will put it into 2.0-alpha2.
Thanks,
-t
Comment #7
cYu CreditAttribution: cYu commentedOk, I've moved that code into it's own function. My testing indicated that .end() was not needed in the places I was using it so I removed those calls.
Comment #8
ulechka CreditAttribution: ulechka commentedHello!
I've changed your patch a little, just added nid to autocompletion field this way:
$emptyAutos.eq(0).val(title + ' [nid:' + nid + ']').change();
and now inline references really works for me after popups "Add new [node-type]"