Interesting. Thanks for sharing/mentioning.. I can see an
implementation of this indeed when dealing with a cms or just already
available code you must tweak or abuse :)
On Sep 3, 5:45 am, Aaron Newton wrote:
> I agree; it's my preference to use the js notation for creating elements,
> but some
I agree; it's my preference to use the js notation for creating elements,
but sometimes you need to use a string. Templates are a great example of
this concept, where you need to do variable substitution and whatnot.
On Wed, Sep 2, 2009 at 7:44 PM, Sanford Whiteman <
sa...@cypressintegrated.com> w
Will I get attacked for wondering about the OO integrity of this
concept? I admit I'm no purist in deed, but speaking theoretically,
manually creating a serialized object in order to instantiate a real
object is questionable.
I had assumed the application for this was one in which
There's actually a solution for you coming in the next MooTools More
(hopefully coming out in a week or so):
http://github.com/mootools/mootools-more/blob/master/Source/Element/Elements.From.js
There are a few things to recognize here:
1) a string of html may return more than one element at the t
@Rolf - I personally find it a nicer syntax for creating elements. So
instead of the following example from mootools (mootools.net/docs/core/
Element/Element#Element):
var myAnchor = new Element('a', {
'href': 'http://mootools.net',
'class': 'myClass',
'html': 'Click me!',
'styles
@Eneko - Thanks for your example. Any reason for removing the closure?
Without it that would create a new div element every time the function
is called, I'm just reusing the same element. I'm now using one line
for the return like you suggested, overlooked that first time:
String.implement({
Hey,
When would you use something like this?
On Sep 2, 10:36 pm, Eneko Alonso wrote:
> You pretty much had it but it is way more simple than that:
>
> String.implement({
> toElement: function() {
> return new Element('div', {html:this}).getFirst();
> }
>
> });
>
> alert('hello'.toEleme
You pretty much had it but it is way more simple than that:
String.implement({
toElement: function() {
return new Element('div', {html:this}).getFirst();
}
});
alert('hello'.toElement().get('id'));
alert('Mootools'.toElement().get('href'));
I like it!
On Tue, Sep 1, 2009 at 1:51 AM,
Maybe String is a better place for it?
String.implement({
toElement: (function() {
var div = new Element('div');
return function() {
div.set('html', this);
return div.getFirst();
}
})()
@ksamdev - Thanks for your example, but that would return a div
element containing the required element. I'd also rather keep the
function on Element rather than its own class, Element seems like the
logical place for this to go, or possibly on String e.g.
'hello'.toElement().get('id');
On Sep
@ksamdev - Thanks for your example, but that would return a div
element containing the required element. I'd also rather keep the
function on Element rather than its own class, Element seems like the
logical place for this to go, or possibly on String e.g.
'hello'.toElement().get('id');
On Sep
var MyElement = new Class({
initialize: function( _str)
{
var _el = new Element( 'div', {
html: _str
});
return $extend( _el, this);
}
});
or just:
return new Element( 'div', { html: _str });
in constructor.
On Aug 31, 7:49 pm, atwork8 wrote:
> Hi,
>
> I thought the
Had the same issue a few months ago and still wondering how to get it
done...
13 matches
Mail list logo