From: Sven S. <s.s...@li...> - 2015-04-17 08:15:40
|
Moin Ronny, > > ** > > Was hälst du von meinem Vorschlag nach CLASS und zusätzlich nach ID zu selektieren. > > 'Wähle den Knotenpunkt im DOM mit der ID "description" der zur Klasse "autocomplete" gehört.' > > |$("#description.autocomplete")|. > > > > Das bringt meiner Meinung das gleiche hohe Maß an Sicherheit (doppelte Sicherheit, weil Klasse und ID übereinstimmen müssen). > > Die Änderungen im Template sind gering und es ist gut lesbar. > > > > Die Elemente die vervollständigt werden sollen, gehören dann zusätzlich zur Klasse "autocomplete". > > > > Macht doch Sinn, oder? > > > Das ist natürlich teilweise Nonsense. > > Die Klassen dürfen natürlich nicht einfach nur "autocomplete" heißen, > sondern "autocomplete-part" oder "autocomplete-customvendor". > $("#description.autocomplete-part") > > Im JS können dann dafür separate Funktionen geschrieben werden. Dann die Frage - warum dann noch auf die id prüfen? Die id ist eindeutig im DOM, das heisst Du beschränkst Dich unnötig auf exakt ein autocompletion Feld pro Seite. Du denkst immernoch in der Richtung "javascript macht aktiv etwas mit der Seite". Denk andersrum: "Das Javascript bietet dem Controller einen Dienst an". Dafür braucht er nur ein eindeutiges Signal, dass er vom Controller kriegen kann, dass seine Dienste gewünscht sind, und ein eindeutiger Klassenname tut da den Dienst wunderbar. Schau übrigens bitte mal nach, welche Klassen ich im partpicker dafür verwendet habe. Ich glaube die sind ähnlich. -- Sven Schöling Entwickler LINET Services GmbH | Cyriaksring 10a | 38118 Braunschweig Tel. 0531-180508-0 | Fax 0531-180508-29 | http://www.linet-services.de LINET in den sozialen Netzwerken: www.twitter.com/linetservices | www.facebook.com/linetservices Wissenswertes aus der IT-Welt: www.linet-services.de/blog/ Geschäftsführung: Moritz Bunkus, Philip Reetz und Timo Springmann HR B 9170 Amtsgericht Braunschweig USt-IdNr. DE 259 526 516 |