javascript - jQuery/XML: synchronizing data and representations using DOM-Mutation-Events -
I am creating a web application that modifies jQuery to represent the data and uses HTML. There may be several representations in a document related to a data node. Users can create them dynamically For example, the data will be represented and can be modified in the table. In addition, the user has the opinion of expanding the "Quick-Overview-Panel" to access specific data.
If a user-control triggers an event => the data must be modified => the need to refresh the same data related to other user-control.
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Synchronize & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Function () {// data $ .ajax ({url: "./data/config.xml", cache: incorrect, async: false, success: init}); var data; function init (d) {data = D; $ ("bottle", data) .bind ("dome atriumified", notification);} function notification (e) {if (e.relatedNode.nodeName == "content") $ (this). Triggers "Changecontent ");} // Presentation-sync $ (". Bottle ", data) .Band (" change content ", function () {$ (" # bottleRep1 ") to deal with Val ($ (this) .attr ("$" ("Bottle", data) .bund ("change content", function () {$ ("# bottle repeat 2"). Val ($ (this) .attr ("content")) ( "Content", $ (this) .val () ($) ("$" $ ("# BottleRep2"). Bine ("change", function () {$ ("bottle", data) .attr (" Content ", $ (this) .val ());});}); & lt; / script> gt; & gt; & gt; body; & lt; body & gt; & lt; div id =" app "& Gt; & lt; span & gt; Bottle-content: & lt; Input ID =" Bottle Repeat 1 "type =" text "value =" test "/> gt; & lt; / span & gt; & Lt ; Span & gt; Bottle-content: gt; & lt; / span & gt; & Lt; / Div & gt; & Lt; / Body & gt;
The real problem is that each user control handles their own modification Change-content handler needs to know the data-modifier, so that representation -Can replace the update, is there a current general solution for this kind of problem? If not, can you make suggestions for a good solution?
You can try to create a custom function to perform some action to trigger to refresh Will handle for $ ('Body') Bind ('foo', function (e, param1, param2) {
alert (param1 + ':' + param2);
});
You can call the above mentioned call on the DTA rite, so that the function is triggered and refreshed - such as $ $ ('body'). Trigger ('Foo', ['Bar', 'Bam']); // Alert 'Bar: Bam'
Comments
Post a Comment