in js file
$('a.ToggleOpen').live("click",function(){
                var searchhtmlid = $(this).attr('rel');
                var filename = String($(this).attr('href').split("?",1));
                var myparams = getparams($(this).attr('href'));
                myparams.pop(myparams);
                idnum = this.id.replace(/ToggleOpen/,'');

                buildingedit( searchhtmlid, filename, myparams);
                return false;
        });

in html file
<a class="ToggleOpen ui-state-default ui-corner-all" rel="descr"
id="ToggleOpen<?= db_result($db_res, $i, "descr_id") ?>"
href="descriptionsadd.php?add=2&did=<?= db_result($db_res, $i,
"descr_id") ?>&showhtml=1">
<span class="ui-icon ui-icon-circle-triangle-e"/>
</a>

nice and clean ;)

On 20 Фев, 13:16, goldy <zlati.pehliva...@gmail.com> wrote:
> issue closed
> thanks mkmanning
> for good advising
>
> On Feb 14, 4:16 pm, goldy <zlati.pehliva...@gmail.com> wrote:
>
>
>
> > hmm, a have tried this
> > <a class="ToggleClose" id="ToggleClose<?= $did ?>"
> > href="descriptionsadd.php?add=2&did=<?= $did ?>&showhtml=2"></a>
> > <script type="text/javascript">
> >         $('a#ToggleClose<?= $did ?>').click(function(){
> >                 buildingedit('#descr', 'descriptionsadd.php', 'did', <?= 
> > $did ?>,
> > 2,this);
> >                 return false;
> >         });
> > </script>
>
> > it's working, but is it what you mean by Inline JavaScript
>
> > On Feb 11, 7:43 pm, mkmanning <michaell...@gmail.com> wrote:
>
> > > Inline JavaScript is generally frowned upon nowadays. A better
> > > approach, if you can do it, is to separate your behavior from your
> > > markup, the same as you separate your structure from your
> > > presentation. It makes for cleaner, more accessible, and more
> > > maintainable code. For the example above:
>
> > > //attach behavior in your jQuery domready function
> > > ...
> > > $('a.ToggleClose').click(function(){
> > > buildingedit('#descr', 'descriptionsadd.php', 'did', <?= $did ?>, 2,
> > > this);
> > > return false;
>
> > > });
>
> > > As you've most likely seen with CSS, this separation has many
> > > advantages relating to purity and maintenance, and unobtrusive
> > > Javascript tends to focus more on enhancing an existing, functional
> > > interface. This subtle difference is important when you're talking
> > > about graceful degradation/progressive enhancement.
>
> > > Just saying. :)
> > > ...
> > > On Feb 11, 9:26 am, brian <bally.z...@gmail.com> wrote:
>
> > > > If you bind your event handlers using an element's onclick attribute
> > > > (or onwhatever) you should write it like so:
>
> > > > onclick="return myClickHandler(...);"
>
> > > > And return false from the function to avoid having the link followed.
>
> > > > Note that the attribute should be all lowercase, btw. The camelcase
> > > > version is used when referring to it as a member of a DOM element, eg.
> > > > some_element.onClick = ...
>
> > > > On Wed, Feb 11, 2009 at 9:28 AM, goldy <zlati.pehliva...@gmail.com> 
> > > > wrote:
>
> > > > > function buildingedit(searchhtmlid, filename, editid, idnum, addnum,
> > > > > obj)
> > > > > {
> > > > >        //closeinst(searchhtmlid);
>
> > > > >        var params = $.evalJSON('{'+editid+':'+idnum+',add:'+addnum
> > > > > +',showhtml:2}');
> > > > >        var myelem = document.getElementById('lastid');
> > > > >        var lastid = myelem.value;
>
> > > > >        var $tablerow = $(searchhtmlid+idnum).clone(true);
>
> > > > >        $(searchhtmlid+lastid).css('background-color','#FFFFFF');
> > > > >        if(lastid)
> > > > >        {
> > > > >                if(lastid!=idnum)
> > > > >                {
> > > > >                        $.get(filename,
> > > > >                                                params,
> > > > >                                                function(returned_data)
> > > > >                                                {
>
> > > > >                                                        var rs = 
> > > > > $('<div id="editwindow" style="display:none;"></
> > > > > div>');
> > > > >                                                        
> > > > > $(searchhtmlid+idnum).hide();
> > > > >                                                        
> > > > > $(searchhtmlid+idnum).after(rs);
> > > > >                                                        
> > > > > //$(searchhtmlid+idnum).css('background-color','#DCE4F5');
> > > > >                                                        
> > > > > $('#editwindow').css('background-color','#DCE4F5');
> > > > >                                                        
> > > > > rs.html(returned_data);
> > > > >                                                        
> > > > > rs.fadeIn(2000, function(){
> > > > >                                                                       
> > > > >  $(this).css('display','block');
> > > > >                                                                });
> > > > >                                                });
>
> > > > >                        myelem.value = idnum;
> > > > >                        setTimeout("prepareForm("+idnum+")", 2000);
> > > > >                }
> > > > >                else
> > > > >                {
> > > > >                        $('div#editwindow').fadeOut(1000, function(){
> > > > >                                                                       
> > > > >                                                                       
> > > > >                    $(this).remove();
> > > > >                                                                       
> > > > >                                                                       
> > > > >                    $(searchhtmlid+idnum).show();
> > > > >                                                                       
> > > > >                                                                       
> > > > >                    });
> > > > >                        myelem.value = 0;
> > > > >                        //closeprev(obj);
> > > > >                }
> > > > >        }
> > > > >        else
> > > > >        {
> > > > >                $.get(filename,
> > > > >                                                params,
> > > > >                                                function(returned_data)
> > > > >                                                {
> > > > >                                                        var rs = 
> > > > > $('<div id="editwindow" style="display:none;"></
> > > > > div>');
> > > > >                                                        
> > > > > $(searchhtmlid+idnum).hide();
> > > > >                                                        
> > > > > $(searchhtmlid+idnum).after(rs);
> > > > >                                                        
> > > > > //$(searchhtmlid+idnum).css('background-color','#DCE4F5');
> > > > >                                                        
> > > > > $('#editwindow').css('background-color','#DCE4F5');
> > > > >                                                        
> > > > > rs.html(returned_data);
> > > > >                                                        
> > > > > rs.fadeIn(2000, function(){
> > > > >                                                                       
> > > > >  $(this).css('display','block');
> > > > >                                                                });
> > > > >                                                });
>
> > > > >                myelem.value = idnum;
> > > > >        }
>
> > > > >        return false;
>
> > > > > }
>
> > > > > and this is called here
>
> > > > > <a class="ToggleClose" onClick="buildingedit('#descr',
> > > > > 'descriptionsadd.php', 'did', <?= $did ?>, 2, this);"
> > > > > href="descriptionsadd.php?add=2&did=<?= $did ?>&showhtml=2" ></a>

Reply via email to