Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Linking from textarea picks up old value #2

Closed
perokvist opened this Issue · 10 comments

4 participants

@perokvist

If fromHandler is "html" and $source is a textarea element, the value is picked up from the textarea element property "text".
However, this is the old unchanged value, so the linking does not work properly.

(The new value is found in the "value" property of textarea. Changing "text" to "value" seems to work fine.)

Update: although, it seems to introduce problems in IE8...

@webwurst

I tried with adding this to line 654 in jquery.views.js:

,
textarea: {
    from: {
        fromAttr: inputAttrib
    },
    to: {
        toAttr: "value"
    }
}

But seems I do not understand enough of the source code, did not work..

Can someone help out?

@webwurst

Ok Firebug is now my friend ;)

In jquery.views.js:32 we check

"$( source ).is( link.from )" 

where source maybe "textarea", but link.from is always:

"input[" + settings.linkToAttr + "]"

because of line 337.

@webwurst webwurst referenced this issue from a commit in webwurst/jsviews
Tobias Bradtke lean workaround for issue #2 while seeking for more wisdom 38e5e10
@BorisMoore
Owner

I plan to add correct support for textarea, along with select, and inputs of various types in addition to text and checkbox etc. Hope to get to it before too long :)

@webwurst

Great! Will it maybe also be possible to link the content of any element with data-to?

Instead of a textarea I would like to use a div with the HTML5-attribute "contenteditable" and use for example the Aloha Editor on that.

@blowsie

Hi , i was just wondering what the progress on this issue was, I was wondering if its worth writing my own hack for now or awaiting the next update.

In my opinion the following need to be considered for linking.

Input (all types, radio, checkbox, text etc)
Textarea
Select
content editable.

ps. I have written a jquery plugin to trigger the change event on contenteditable elements.
Let me know if you wish me to share it.

@BorisMoore
Owner

Hello. I am working hard on moving JsRender towards a final beta API, and making good progress. (It is not visible progress yet, because it will involve a few breaking changes, so I don't want to commit yet - until I am confident enough of the design and have worked through some integration aspects with JsViews to make sure we have compatibility there too.) The plan is to get JsRender to beta (officially the goal is the end of February. May be slightly sooner), and then move to getting JsViews also to beta (goal April...). The JsViews beta will need to include at least inputs, textarea and select. Currently select is tricky because of some issues in IE, but the beta should allow that to work too.

So it may be a little while before you get those features in JsViews, and you may prefer to write your hack if you need it sooner. On content editable, that is also a goal, but probably not for the beta. Is your plugin in on GitHub? If so, do send me a link. (But I may not look at it for a while...)

@BorisMoore
Owner

This issue has been fixed in the latest commit: (pre beta commit counter: 8).
Binding to textarea now supported, with demo here:
http://borismoore.github.com/jsviews/demos/step-by-step/07_form-elements.html

@BorisMoore BorisMoore closed this
@blowsie

Boris, do you have any plans to create a changeHandler for html5 contenteditable?

@blowsie

This is the change event I wrote, you asked to take a peek a while back.

(function ($) {
    $.fn.wysiwygEvt = function () {
        return this.each(function () {
            var $this = $(this);
            var htmlold = $this.html();
            that.bind('blur keyup paste copy cut mouseup', function () {
                var htmlnew = $this.html();
                if (htmlold !== htmlnew) {
                    $this.trigger('change')
                }
            })
        })
    }
})(jQuery);

You can simply call $('.wysiwyg').wysiwygEvt();

Id image this isn't much use in jsviews tho.

@BorisMoore
Owner

@blowsie: No plans right now. But it would be a good feature request, and if you want to create an issue to track it, I will triage it, probably as a post V1.1 feature request. Thanks...! We can link the issue (if you create one) back to here, and your code example...

@aredridel aredridel referenced this issue from a commit in blumenthals/RapidWeb
@BorisMoore Added support for data-linking to textarea elements (BorisMoore/jsvie…
…ws#2)

Improved sample for form elements, and included textarea example.
http://borismoore.github.com/jsviews/demos/step-by-step/07_form-elements.html
Integrated updated design for #index, from JsRender.
Signed-off-by: Boris Moore <borismoore@gmail.com>
89354dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.